Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Simple City DB for Django, includes Ajax select filtering.

Notifications You must be signed in to change notification settings

dpnova/django-simple-cities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This code is old and probably not compatible with anything anymore. It has been archived.

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 }}

About

Simple City DB for Django, includes Ajax select filtering.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages