#django-locality#
django-locality
is a pretty simple library geared at making things easy when it comes to countries and territories. It comes with a bunch of nice initial data, so you'll be able to immediately get up to speed tying objects to countries and territories.
For example, you can list all countries like so:
locality.models.Country.objects.all()
You can also find all territories by country like so:
for country in locality.models.Country.objects.all():
country.territories
You can create your own models around countries and territories:
class Address(models.Model):
country = models.ForeignKey('locality.models.Country')
territory = models.ForeignKey('locality.models.Territory')
Eventually, this Django module will include nice little helpers like template tags, but for now, it simply makes it easy for you to work with countries and territories.
There are some nice views included for getting values in serialized form, as well as some nifty form fields and widgets. Some url patterns are supplied to demonstrate serialization using the views.
It's ridiculously simple, yet somehow doesn't exist in the Django-sphere. Please report all bugs to the Git Issue-Tracker, and enjoy the library :)
##South Support##
Support for South has been added. If you have previously installed django-locality
and ran syncdb
, you will need to run the following commands:
python manage.py migrate locality 0001 --fake
python manage.py migrate locality
The first migration must be ran with --fake
since it will attempt to create the tables django-locality
uses. The second command will run any additional migrations.
If you have not previously used django-locality
you should run the following commands:
python manage.py syncdb
python manage.py migrate locality
Or, simply:
python manage.py syncdb --migrate