Django Locality Two - Countries and Territories
Project description
# django-locality-two
django-locality-two is a drop-in replacement for django-locality with modern python (3.5+) and django (1.11+) support, and more tests. Locality is a light collection of helpers for handling countries and territories in Django.
Currently, it includes:
locality.json, a fixture with the world’s countries and territories (if you notice any missing, [open an issue](https://github.com/dekomote/django-locality-two/issues) or [submit a pull request](https://github.com/dekomote/django-locality-two/compare/))
views returning serialized lists of countries and territories
simple form field and widget
## Installation
Install from the cheese shop
pip install django-locality-two
OR
Install from GitHub with pip:
pip install -e git+https://github.com/dekomote/django-locality-two.git#egg=django-locality-two==2.1.1
Then add locality to INSTALLED_APPS in your Django settings. To load the included data, run:
python manage.py loaddata locality
(or whichever equivalent method you use to run “manage.py” commands)
## Usage
List all countries:
>>> from locality.models import Country >>> print Country.objects.all() [<Country: Andorra>, <Country: United Arab Emirates>, <Country: Antigua and Barbuda>, ...]
or list territories by country:
>>> from locality.models import Country >>> for country in locality.models.Country.objects.all(): >>> print country.territories.all() ... [<Territory: Salta, Argentina>, <Territory: Buenos Aires, Argentina>, <Territory: Ciudad Autónoma de Buen os Aires, Argentina>, ...]
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’)
## Bugs / TODO
Please report all bugs to the [GitHub issue tracker](https://github.com/dekomote/django-locality-two/issues)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_locality_two-3.1.tar.gz.
File metadata
- Download URL: django_locality_two-3.1.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
258d62c0bc45a0762ff2aeeed199aa846b2395402882bae4de0d222db7923f7f
|
|
| MD5 |
f103304a1dfb7d285c12aae29fd78f76
|
|
| BLAKE2b-256 |
b2c0455ef39d60c469b458b05bd044a79ec7c1662f177333d05913ba8d5f753d
|
File details
Details for the file django_locality_two-3.1-py3-none-any.whl.
File metadata
- Download URL: django_locality_two-3.1-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a211953258838f76092d7956ec5139b6f17c51cb2a83086afdfdc8584a190de
|
|
| MD5 |
1fac31c185a8d13841afe44078f1c3e2
|
|
| BLAKE2b-256 |
e563c4463a84f0e3ea058644f88281c7d838e8c39ef093c81cf2b98dd82ff612
|