我想知道为什么我ImportError
在使用django-cities时会得到一个。
from cities.models import PostalCode
我已经同步cities
了数据库,并且数据库中存在表。追溯:
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
ImportError 表明 python 正在寻找PostalCode
in haystack
,但我要求它从 . 导入cities
。为什么会发生这种情况?谢谢你的想法!