Allow empty or null ChoiceField
Closed this issue · 1 comments
anuj-scanova commented
If a ChoiceField
is added to the search form, when the search is made, the choice field always gets into the queryset with the first value as default selected.
It is not always necessary that the search should include the value from the ChoiceField.
It is possible to allow empty
or null
value to the Choice field and it should be added to the queryset if is not null?
anuj-scanova commented
Resolved this issue by passing empty value as
invoice_type = forms.ChoiceField(
required=False,
choices=[('', '---')] + Payment.INVOICE_TYPES
)
for ModelChoiceField
, add empty_label='---'
attribute