Skip to content

CountryField empty option when CountryType is nullable #141

Description

@TrilceAC

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions