嗨,我是 Django 的新手,我已尽力理解它,但我还有很长的路要走。我正在开发一个项目,我想在其中使用 django tables2 创建 HTML 表。几天来我一直在尝试导入 django 表,但仍然没有运气......请帮助我。
尝试导入 django_tables2 时出现此错误
$ python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django_tables2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\django_tables2\__init__.py", line 3, in <module>
File "build\bdist.win32\egg\django_tables2\tables.py", line 4, in <module>
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.
当我从 forms.py 导入时,我得到错误未解决的导入。请帮助我,一步一步地告诉我如何正确地做到这一点。非常感谢。