I’m wondering why I am getting an ImportError when using django-cities.
from cities.models import PostalCode
I have already synced db and cities tables exist in the database. The traceback:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/lib/python2.7/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/lib/python2.7/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/lib/python2.7/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/lib/python2.7/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/lib/python2.7/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/lib/python2.7/South-0.7.5-py2.7.egg/south/management/commands/__init__.py", line 10, in <module>
import django.template.loaders.app_directories
File "/lib/python2.7/django/template/loaders/app_directories.py", line 23, in <module>
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError haystack: cannot import name PostalCode
The ImportError suggests that python is looking for PostalCode in haystack, but I am asking it to import from cities.. Why does this happen? Thanks for your ideas!
I figured out the problem. Although both the github and pypi versions claim to be 0.2, it turns out that they are different. I installed via pip, and the pypi version does not have a
PostalCodemodel class, which was the source of myImportError. Thanks!