Loading...

django-developers@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Discrepancy involving choices with ModelForm and Form Stuart Laughlin Tue Feb 21 17:01:04 2012

Greetings Everyone --

It seems to me there is a discrepancy between ModelForm and Form when
it comes to fields with choices. When I create a ModelForm from a
model having a CharField with choices set, the resultant form contains
a select with a blank choice included by default. On the other hand,
when I create a Form and give it a ChoiceField, the resultant form
contains a select *without* a blank choice included by default.

In other words, I can't think of why this form field declaration...

my_form_field = forms.ChoiceField(choices=MY_CHOICES)

...shouldn't result in a Select widget with a blank choice included.
And that goes double if I set required=False.

I searched for a ticket along these lines but didn't find anything.
I'm not an experienced django contributor, so I'm posting here hoping
for some feedback to verify that I'm on the right track (or not), i.e.
is this something that I ought to create a ticket for (and some tests
and a patch)?

Thanks,

--Stuart

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