areski/django-cities
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
django-cities - Place models and data for Django apps ===================================================== This project includes country, region, city, and district models and is prepopulated with data from GeoNames. The GeoNames import script is also included if you'd like to re-import the data yourself, or change the way in which it gets cleaned up. Includes 234 counties, 2,610 regions, 97,949 cities and 606 districts For more information and examples see http://www.coderholic.com/django-cities-countries-regions-cities-and-districts-for-django/ Examples: ========= Finding all London boroughs: >>> london = City.objects.filter(country__name='United Kingdom').get(name='London') >>> boroughs = District.objects.filter(city=london) Nearest city to a given lat,lon: >>> City.objects.nearest_to(51, 1) <City: Dymchurch, Kent, United Kingdom> 5 Nearest cities to London: >>> london = City.objects.filter(country__name='United Kingdom').get(name='London') >>> nearest = City.objects.distance(london.location).exclude(id=london.id).order_by('distance')[:5]