Django Country/State/Province/Territory info with django-locality

I’ve just written a new Django app called django-locality. It’s a pretty simple Django application which includes a few key features:

  1. Country objects stored in the database.
  2. Territory objects stored in the database.
  3. Each country has 0 or more territories.
  4. View functions to get territories by country, all territories, all countries, or a country.
  5. Territories have abbreviations and names.
  6. 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`.