Customize/remove Django select box blank option

Haven’t tested this, but based on reading Django’s code here and here I believe it should work:

class ThingForm(forms.ModelForm):
  class Meta:
    model = Thing
  
  def __init__(self, *args, **kwargs):
    super(ThingForm, self).__init__(*args, **kwargs)
    self.fields['verb'].empty_label = None

EDIT: This is documented, though you wouldn’t necessarily know to look for ModelChoiceField if you’re working with an auto-generated ModelForm.

EDIT: As jlpp notes in his answer, this isn’t complete – you have to re-assign the choices to the widgets after changing the empty_label attribute. Since that’s a bit hacky, the other option that might be easier to understand is just overriding the entire ModelChoiceField:

class ThingForm(forms.ModelForm):
  verb = ModelChoiceField(Verb.objects.all(), empty_label=None)

  class Meta:
    model = Thing

Leave a Comment