django / django-localflavor

Country-specific Django helpers, formerly of contrib fame

Home Page:https://django-localflavor.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: Form and model field for country?

yourcelf opened this issue · comments

Would a form field and model field for specifying a Country be within the scope of django-localflavor?

The localflavor.generic.countries.iso_3166 module already contains a list of ISO 3166-1 alpha-2 country codes. This could be trivially updated to include the name of the country as a two-tuple (similar to us_states), and then a trivial form field and model field with the country names as choices and alpha-2 codes as values.

If this sounds like a good idea, I'll send a PR.

Sorry for the delay in responding to this. I don't think it's a good idea to include this feature because there's already a very good Django module that covers this functionality.
https://github.com/SmileyChris/django-countries

The ISO 3166-1 alpha-2 country codes were only added for validation of BIC numbers without having to include django-countries for all django-localflavor users.

For some background, we used to have phone number fields in django-localflavor but we removed them in 2.0 because django-phonenumber-field provided a better version of what we had. Merging your PR would put us in the same spot with respect to country codes: we'd have a less functional version when a fully-maintained library already provides a version with more features.

This isn't the last word on this. I'm one of a few maintainers but I seem to be the most active one right now. I'll leave this issue and PR open for a month or so to enable other maintainers to give their input. If they agree or we don't hear anything further, I will close this issue and the associated PR.

I was also surprised the functionality didn't exist. I agree that duplication is bad and wonder if there'd be a logical way to incorporate the 3rd party library as a "best practice" e.g. in a documentation section for "country codes".

Closing as per Ben's comments above.