On Friday, January 7, 2011 4:47:43 PM UTC, ShawnMilo wrote: > > On 01/07/2011 11:33 AM, hank23 wrote: > > I want to code a form which will have a choice field which I want to > > have rendered as a dropdown box in my html file. How do I code the > > choices parameter in the form definition to bind it to a column in one > > of my data tables in my model? The documentation shows a few examples, > > but nothing specifically for choice fields. Please explain. Thanks. > > > > You have to use a ModelForm for this. > > <snip> > > Technically you can do it with a forms.Form, but you have to do the > entire thing manually, which is a big waste. > > <snip> > > Shawn >
Er, no, both wrong. The source of choices for a field has nothing to do with whether or not it's a modelform, and there is an easy built-in field class for managing exactly what the OP requested: ModelChoiceField. This takes a `queryset` parameter, which provides the data for the field choices. See the docs: http://docs.djangoproject.com/en/1.2/ref/forms/fields/#modelchoicefield -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.