This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME
32 lines (22 loc) · 1.47 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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 }}