On 22 February 2012 08:43, Stuart Laughlin <[email protected]> wrote:
> Carl --
>
> Thanks for the feedback!
>
> On Feb 21, 7:47 pm, Carl Meyer <[email protected]> wrote:
>>
>> It's
>> important that you can get full control at some level - if a blank
>> option were automatically added to ChoiceFields, how would you propose
>> that a developer remove it if they didn't want it?
>>
>
> I would propose...
>
> my_form_field = forms.ChoiceField(choices=MY_CHOICES,
> include_blank=False)
>

But what would be the label for this automatically generated blank
choice and how do you change it ? I guess, you'll need an
"empty_label" option [1]. So now we added two extra params which take
literal values and gained zero functionality or readability. We could
actually only have the empty_label thing and thus make it consistent
with ModelChoiceField. But I still think this isn't a good idea,
because "magically" adding extra stuff where the user doesn't expect
that is bad.

ModelForms is a different case, as it auto generates forms from
models. That's pretty "magic" already, so an extra label shouldn't
surprise you.

[1]: 
https://docs.djangoproject.com/en/1.3/ref/forms/fields/#django.forms.ModelChoiceField.empty_label

-- 
Łukasz Rekucki

-- 
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.

Reply via email to