geoDjango - ImportError:无法导入名称SpatialBackend

时间:2011-12-02 16:00:08

标签: django geodjango importerror

我正在尝试使用 geoDjango 制作应用,但实际上我遇到了一些问题要让它运行。 当我执行“ python manage.py syncdb ”命令时,出现以下错误:

File "/media/datos/Proyectos/CualBondi/git/cualbondi/myapp/models.py", line 10, in <module>
from django.contrib.gis.db import models
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/__init__.py", line 5, in <module>
from django.contrib.gis.db.models.aggregates import *
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/aggregates.py", line 2, in <module>
from django.contrib.gis.db.models.sql import GeomField
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/sql/__init__.py", line 2, in <module>
from django.contrib.gis.db.models.sql.query import GeoQuery
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/sql/query.py", line 4, in <module>
from django.contrib.gis.db.models.fields import GeometryField
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/fields/__init__.py", line 3, in <module>
from django.contrib.gis.db.backend import SpatialBackend, gqn
ImportError: cannot import name SpatialBackend

我在这里给你一些额外的信息:

  • Django 1.3.1
  • Python 2.6
  • Ubuntu 10.04
  • PostgreSQL 8.4.8
你知道吗? 非常感谢你!

1 个答案:

答案 0 :(得分:0)

也许这有帮助,SpatialBackend似乎已被弃用。阅读下面的警告。

$ python manage.py shell
Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.gis.db.backend import SpatialBackend, gqn
/usr/lib/pymodules/python2.7/django/contrib/gis/db/backend/__init__.py:5: UserWarning: The `django.contrib.gis.db.backend` module was refactored and renamed to `django.contrib.gis.db.backends` in 1.2.  All functionality of `SpatialBackend` has been moved to the `ops` attribute of the spatial database backend.  A `SpatialBackend` alias is provided here for backwards-compatibility, but will be removed in 1.3.
  warn('The `django.contrib.gis.db.backend` module was refactored and '
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: cannot import name gqn

我在django 1.3.0上,似乎工作得很好,但只是警告。