当我使用
from django.contrib.gis.db import models
我得到错误:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from django.contrib.gis.db import models
File "C:\Python27\lib\site-packages\django\contrib\gis\db\models\__init__.py"
, line 2, in <module>
from django.db.models import *
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184,
in inner
self._setup()
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 40,
in _setup
raise ImportError("Settings cannot be imported, because environment
variable %s
is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
如何解决?
使用时
from django.db import models
django 工作没有问题