How to install django-cities and populate country region state and city drop-down
1)
a)
#easy_install django-cities
Note: easy_install did not work for me. I got following errror when tried to run "./manage.py cities --import=all"
AttributeError: type object '' has no attribute 'plugins'
b)
Works
---------
activate virtualenv
#git clone https://github.com/coderholic/django-cities.git
#cd django-cities
#python setup.py install
2)
Add 'cities' to INSTALLED_APPS in your projects settings.py file
3)
Change db backend
Goto settings.py and add/replace following line in DATABASES dictionary.
*'ENGINE': 'django.contrib.gis.db.backends.mysql'
4)
Create tables for the cities app
#python manage.py syncdb
5)
Optional
Add following file in settings.py
GEOS_LIBRARY_PATH = '/home/saju/horizon_test/geos-3.3.8/capi/.libs/libgeos_c.so'
6)
a)
#Download all data files to .venv/lib/python2.7/site-packages/django_cities-0.2-py2.7.egg/cities/data
#Then insert data to all tables
#./manage.py cities --import=all
b)
#Download only country file to .venv/lib/python2.7/site-packages/django_cities-0.2-py2.7.egg/cities/data
#Then insert data to country table
#./manage.py cities --import=country
c)
#./manage.py cities --help
d)
Debug: Clear downloaded files from following path and run "./manage.py cities --import=all" again.
#cd .venv/lib/python2.7/site-packages/django_cities-0.2-py2.7.egg/cities/data
7)
Test
#python manage.py shell
>>> import cities
>>> cities.models.Country.objects.all()[1]
1)
a)
#easy_install django-cities
Note: easy_install did not work for me. I got following errror when tried to run "./manage.py cities --import=all"
AttributeError: type object '' has no attribute 'plugins'
b)
Works
---------
activate virtualenv
#git clone https://github.com/coderholic/django-cities.git
#cd django-cities
#python setup.py install
2)
Add 'cities' to INSTALLED_APPS in your projects settings.py file
3)
Change db backend
Goto settings.py and add/replace following line in DATABASES dictionary.
*'ENGINE': 'django.contrib.gis.db.backends.mysql'
4)
Create tables for the cities app
#python manage.py syncdb
5)
Optional
Add following file in settings.py
GEOS_LIBRARY_PATH = '/home/saju/horizon_test/geos-3.3.8/capi/.libs/libgeos_c.so'
6)
a)
#Download all data files to .venv/lib/python2.7/site-packages/django_cities-0.2-py2.7.egg/cities/data
#Then insert data to all tables
#./manage.py cities --import=all
b)
#Download only country file to .venv/lib/python2.7/site-packages/django_cities-0.2-py2.7.egg/cities/data
#Then insert data to country table
#./manage.py cities --import=country
c)
#./manage.py cities --help
d)
Debug: Clear downloaded files from following path and run "./manage.py cities --import=all" again.
#cd .venv/lib/python2.7/site-packages/django_cities-0.2-py2.7.egg/cities/data
7)
Test
#python manage.py shell
>>> import cities
>>> cities.models.Country.objects.all()[1]
https://github.com/coderholic/django-cities
ReplyDeletePath are not clear. where is setting.py? where run command "python manage.py syncdb" ?
Delete