If the model field is a selection or a foreign key, the widget on the page is the selected input or radio, if you specify this. Django places "---------" in the first element as an unselected value. How can I override or delete it? I remember reading the way to do this, but I can no longer find it.
See: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
, "", . , . , . , blank = False ( ).
Django forms doc:
<select>, ModelChoiceField, . ( "---------" ) empty_label, , empty_label=None:field2 = forms.ModelChoiceField(queryset=..., empty_label=None)
<select>, ModelChoiceField, . ( "---------" ) empty_label, , empty_label=None:
<select>
ModelChoiceField
empty_label
empty_label=None
field2 = forms.ModelChoiceField(queryset=..., empty_label=None)
ModelForm, .
ModelForm
If it is ModelForm, just set default=Nonein your model, for example:
default=None
choose = models.CharField(max_length=3, choices=choose_dict, default=None)