There might be cases where a CountryField should allow to select an empty/blank option: If the model has columns of CountryType which are nullable, the related CountryField should allow the empty option.
At the moment I have tried to fake the form field choices when the form is created, but with no luck because at some point there are failed coercions to Country that fails. This doesn't work:
class PersonForm(ModelForm):
# ...
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.country.choices = [(None, '')] + self.nacionalidad.choices()
How should be handled the fact that the country field might be optional?
There might be cases where a
CountryFieldshould allow to select an empty/blank option: If the model has columns ofCountryTypewhich arenullable, the relatedCountryFieldshould allow the empty option.At the moment I have tried to fake the form field
choiceswhen the form is created, but with no luck because at some point there are failed coercions toCountrythat fails. This doesn't work:How should be handled the fact that the country field might be optional?