1

Shis 是我在尝试使用以下命令从 django.contrib.gis.db 导入模型时遇到的错误

from django.contrib.gis.db import models

我想这样做来定义地理模型。我收到下面提到的错误。

伙计们请帮帮我。

from django.contrib.gis.db import models
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/gis/db/models/__init__.py", line 2, in <module>
    from django.db.models import *
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named py

这是我在终端中获得的完整回溯。

4

1 回答 1

10

你正在做的地方import settings.py而不是import settings.

于 2012-06-13T08:09:29.240 回答