Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple City DB for Django, includes Ajax select filtering.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
simplecities
.gitignore
README
setup.py

README

This is a very small app to let you easily add Country/City selects with filtering. So you pick a country and it filters the list of cities. The data is from http://www.geonames.org/ so you better make sure you satisfy their licensing conditions. :)

This was inspired by wanting to use django-cities ( https://github.com/coderholic/django-cities ) for some simple form stuff and being put off by having to install GeoDjango.

I'm pretty responsive, so please flame, or preferrably contribute patches!

1. Download the files:
    http://download.geonames.org/export/dump/countryInfo.txt
    http://download.geonames.org/export/dump/cities1000.zip

2. Add "simplecities" and "smart_selects" (pip install smart-selects) to your INSTALLED_APPS setting. smart-selects: https://github.com/digi604/django-smart-selects

3. Add the required smart-selects urls:
	url(r'^chaining/', include('smart_selects.urls')),

3. Run "./manage.py syncdb" (or "./manage.py migrate simplecities" if you use South)

4. Run the command to load the data:
 	manage loadsimplecities /path/to/cities1000.txt /path/to/countryInfo.txt

5. Use the location form:
	from simplecitites.forms import LocationForm
	def location_details(request):
		location_form = LocationForm(request.POST or None)
		return render(request,'some_template.html',{
			"location_form": location_form
		})

6. Render the form in the template:
	{{ location_form }}
Something went wrong with that request. Please try again.