I’ve just written a new Django app called django-locality. It’s a pretty simple Django application which includes a few key features:
- Country objects stored in the database.
- Territory objects stored in the database.
- Each country has 0 or more territories.
- View functions to get territories by country, all territories, all countries, or a country.
- Territories have abbreviations and names.
- Countries have ISO 3166-1 Alpha 2 Names (2 digit unique abbreviations), ISO 3166-1 Alpha 3 names (3 digit unique abbreviations), and each uses its country code number as its id.
This opens up a lot of possibilities. Simply add
'locality' to your
INSTALLED_APPS in your
settings.py file, run
syncdb to install the models and the initial data, and off you go. You can tie your own custom classes to countries and territories like any other Django object.
It’s really simple, but it’s really refreshing to finally be able to do things in a way that makes sense. The module is available on PyPI, so you can integrate it into your build process with `setuptools`.