I have a Flight model which has a foreignkey field that relates to a
route object. I created a custom field to go with my FlightForm that
allows me to enter a simple string, which is then, via the clean()
method, constructed into a Route object that is attached to the
flight. This works fine, but what I'm trying to do now is have it so
when I create a FlightForm formset, my route field is rendered as a
textbox with the __unicode__ representation, instead of just the
primary key as it is now. How can I do this? I understand I need to be
making a custom widget not a custom field to do this, right? This is
what I have so far:

###############

class RouteWidget(widgets.TextInput):
    def render(self, name, value, attrs=None):
        return mark_safe("<input class='route_line' type='text'
value='" + str(value) + "' name='" + name + "'/>")

###############

The problem is that the "value" value is never anything other than
None. Even though the form is being populated via a formset. What am I
missing here? The name attribute seems to be working...
--~--~---------~--~----~------------~-------~--~----~
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