Giter Club home page Giter Club logo

django-locality-two's Introduction

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 or submit a pull request)
  • 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

django-locality-two's People

Contributors

dekomote avatar lacrymology avatar mariocesar avatar naftulikay avatar supervacuo avatar yourcelf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.