[Django]-Disable the empty option in Django ModelForm

4πŸ‘

βœ…

Err my bad, I should have looked carefully at the docs. Anyway here is the solution:

By default the widget used by ModelChoiceField will have a an empty choice at the top of the list. You can change the text of this label (which is β€œβ€”β€”β€”β€ by default) with the empty_label attribute, or you can disable the empty label entirely by setting empty_label to None

πŸ‘€phunehehe

Leave a comment