Metadata-Version: 2.4
Name: django-locality-two
Version: 4.0
Summary: Django Locality Two - Countries and Territories
Home-page: https://github.com/dekomote/django-locality-two/
Author: Dejan Noveski
Author-email: dr.mote@gmail.com
License: MIT
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: django<6,>=1.11
Dynamic: license-file

# django-locality-two

`django-locality-two` is a drop-in replacement for django-locality with modern python (3.5+) and django (1.11 up to 5.2) 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==4.0

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)
