django-localflavor
django-localflavor copied to clipboard
Proposal: Interface for using country submodules generically
The use case is having a country selector and then based upon the country that is selected displaying a select input field for the regions for that country. I am doing this for a client currently so this gist is hardcoded a bit for their needs (not options expansion for the field, etc.) but wouldn't take much to make this more generally usable.
I recognize that it would be hard to make this pattern cover ALL uses the different locale specific constants/objects, but if this approach I am taking would be generally useful for inclusion in this package, i would be happy to work on something for a proper PR.
https://gist.github.com/paltman/7551838
Any feedback/thoughts?
Interesting, I think that would be useful for cases in which a site has a target audience of a couple of countries, such as US/Canada or Germany/Austria/Switzerland etc. Did you end up using something like the gist in your client project?
I'm curious, would it be possible to pick some inspiration from https://github.com/mthornhill/django-postal too? For international sites, providing reasonable address inputs + validation is quite hard. Currently I just follow the fields of the payment gateway, but there is hardly any validation.
Problematic are provinces vs states, double localizing (de.DEZipCode us.USZipCode, DEStateSelect,...). I propose to move everything general into the generic package and put the country data and country specific stuff into the country packages.