documentation error on ModelForm ModelChoiceField empty option
|Reported by:||Carl Meyer||Owned by:||Carl Meyer|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The ModelForms documentation at the bottom of the "field types" list states:
The blank choice will not be included if the model field has blank=False and an explicit default value (the default value will be initially selected instead).
It is true that the default value is initially selected if given, but it is not true that the "blank choice will not be included". It is included regardless, unless empty_label is explicitly set to None.
I would consider the documented behavior here to be better than the actual behavior, but given backwards-compatibility it's probably the docs that need to change.
Change History (7)
comment:1 Changed 8 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|