在有关 Models 的 Django 文档中,我被要求运行的第一个命令和 python 的响应是:
>>> from django.db import models
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from django.db import models
File "C:\Python26\lib\site-packages\django\db\__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\Python26\lib\site-packages\django\utils\functional.py", line 184, in inner
self._setup()
File "C:\Python26\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.
从堆栈跟踪中可以看出,我正在 python 2.6.6 中运行 django 服务器。谁能给我一个线索,让我从本教程的右脚开始?提前致谢。