Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CountryField empty option when CountryType is nullable #141

Open
TrilceAC opened this issue Jan 30, 2019 · 0 comments
Open

CountryField empty option when CountryType is nullable #141

TrilceAC opened this issue Jan 30, 2019 · 0 comments

Comments

@TrilceAC
Copy link
Contributor

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?

@TrilceAC TrilceAC changed the title CountryField emptty option when CountryType is nullable CountryField empty option when CountryType is nullable Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant