1👍
Manually setting the options that come from a model is often not a good idea. Typically a ModelChoiceField
[Django-doc] is used.
You can set the empty_label
to None
to disable it, so:
class MyForm(forms.Form):
some_field = forms.ModelChoiceField(
queryset=SomeModel.objects.filter(type=1, is_active=True).order_by('pk'),
empty_label=None
)
Source:stackexchange.com