Sure, here's a minimal version of them (I skipped fields that aren't too
relevant to the problem at hand because there's many, including tons of
foreign keys):

class Target(Model):
    name = CharField("Target Name", max_length=255, unique=True)
    created = DateTimeField(auto_now_add=True, editable=False)
    modified = DateTimeField(auto_now=True, editable=False)

class Ticket(Model):
    target = ForeignKey(Target, related_name="tickets")
    reference = CharField(max_length=255)
    created = DateTimeField(auto_now_add=True, editable=False)
    modified = DateTimeField(auto_now=True, editable=False)

On Wed, Apr 20, 2011 at 12:35 PM, DrBloodmoney <drbloodmo...@gmail.com>wrote:

> On Wed, Apr 20, 2011 at 12:30 PM, Daniel Gagnon <redalas...@gmail.com>
> wrote:
> > Thanks
> > It still doesn't work though. I found out through logging that value that
> is
> > receive is an int (the id) instead of being the object itself. How can I
> > make my widget pass the object itself to the widget instead of passing
> > object.id ?
> > On Wed, Apr 20, 2011 at 12:17 PM, DrBloodmoney <drbloodmo...@gmail.com>
> > wrote:
> >>
> >> On Wed, Apr 20, 2011 at 11:48 AM, Daniel Gagnon <redalas...@gmail.com>
> >> wrote:
> >> > So far, I have the following code:
> >> > from django.forms.widgets import TextInput
> >> > from django.forms.fields import Field
> >> > class AutoCompleteWidget(TextInput):
> >> >     def render(self, name, value, attrs=None):
> >> >         if hasattr(value, 'name'):
> >> >             v = value.name
> >> >         else:
> >> >             v = None
> >> >         super(AutoCompleteWidget, self).render(self, name, v, attrs)
> >> > class AutoCompleteField(Field):
> >> >     widget = AutoCompleteWidget
> >> >     def clean(self):
> >> >         pass    # Not implemented yet
> >> > class TicketForm(ModelForm):
> >> >     target = AutoCompleteField()
> >> >     class Meta:
> >> >         model = Ticket
> >> >         exclude = ('slug')
> >> >
> >> > When I use this code the whole form stops rendering! What's wrong with
> >> > my
> >> > widget?
> >>
> >> Take out the self in the super call
> >> (ie) Change this:
> >>
> >> super(AutoCompleteWidget, self).render(self, name, v, attrs)
> >>
> >> to this:
> >>
> >> super(AutoCompleteWidget, self).render(name, v, attrs)
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
>
> Could you also include the model?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to