可能重复:
在 Django 上设置 geoip 时出错
我从浏览器收到“无法导入名称 GeoIP”错误,但在 python 终端上却没有。例如 /tmp/geo 中的地理数据。以下适用于 python 终端。
from django.contrib.gis.geoip import GeoIP
GeoIP(path='/tmp/geo/')
但是 Django 视图中的以下内容给出了错误
from django.contrib.gis.geoip import GeoIP
return HttpResponse (GeoIP(path='/tmp/geo/'))
任何指针都会有所帮助。我正在使用 django 1.4,python 2.6。这是痕迹。谢谢。
Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
101. request.path_info)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
300. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
209. return ResolverMatch(self.callback, args, kwargs, self.name)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in callback
216. self._callback = get_callable(self._callback_str)
File "/usr/lib/python2.6/site-packages/django/utils/functional.py" in wrapper
27. result = func(*args)
File "/usr/lib/python2.6/site-packages/django/core/urlresolvers.py" in get_callable
92. lookup_view = getattr(import_module(mod_name), func_name)
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/x/y/z/views.py" in <module>
12. from django.contrib.gis.utils import GeoIP
Exception Type: ImportError at /
Exception Value: cannot import name GeoIP