Skip to main content
 首页 » 编程设计

python之django-tracking 与 Django 1.6 不兼容

2024年08月28日27lhb25

我正在尝试将 Django 1.3 应用程序转换为 Django 1.6。我正在使用 django-tracking 包,但是当我启动 runsever 时,出现以下错误:

Unhandled exception in thread started by <function wrapper at 0x10868e9b0> 
Traceback (most recent call last): 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/utils/autoreload.py", line 93, in wrapper 
    fn(*args, **kwargs) 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 101, in inner_run 
    self.validate(display_num_errors=True) 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate 
    num_errors = get_validation_errors(s, app) 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors 
     for (app_name, error) in get_app_errors().items(): 
 File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors 
    self._populate() 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in _populate 
    self.load_app(app_name) 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app 
    models = import_module('%s.models' % app_name) 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module 
    __import__(name) 
  File "/Users/athom09/Projects/openemory1.6/openemoryEnv/lib/python2.7/site-packages/tracking/models.py", line 5, in <module> 
    from django.contrib.gis.utils import HAS_GEOIP 
ImportError: cannot import name HAS_GEOIP 

请您参考如下方法:

答案在这里:
https://docs.djangoproject.com/en/1.4/ref/contrib/gis/geoip/#module-django.contrib.gis.geoip

在 Django 1.6 中,所需的导入已更改为:
从 django.contrib.gis.utils 导入 HAS_GEOIP

致:
从 django.contrib.gis.geoip 导入 HAS_GEOIP