【发布时间】:2015-06-07 17:06:45
【问题描述】:
Traceback (most recent call last):
File "C:\Users\SAGAR\Desktop\venv\lib\site-packages\django\core\management\__init__.py", line 179, in fetch_command
app_name = commands[subcommand]
KeyError: 'startprojecttest_project'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\Scripts\django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "C:\Users\SAGAR\Desktop\venv\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Users\SAGAR\Desktop\venv\lib\site-packages\django\core\management\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\SAGAR\Desktop\venv\lib\site-packages\django\core\management\__init__.py", line 182, in fetch_command
settings.INSTALLED_APPS
File "C:\Users\SAGAR\Desktop\venv\lib\site-packages\django\conf\__init__.py", line 48, in __getattr__
self._setup(name)
File "C:\Users\SAGAR\Desktop\venv\lib\site-packages\django\conf\__init__.py", line 42, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
我是 Django 的新手,我刚刚安装了 Django,我尝试使用命令 ((venv) C:\Users\SAGAR\Desktop\venv>python .\Scripts\django-admin.py startproject test_project) 创建一个 new_project,但我得到了这样的错误,我还设置了环境变量,如 --
C:\Python34;C:\Python34\Scripts;C:\Python34\python.exe;C:\Python34\Lib\site-packages\django\bin;
【问题讨论】:
-
你按照回溯告诉你的去做了吗?
-
不,实际上我不明白回溯在告诉什么
-
谢谢,我忘了 startproject 和 test_project 之间的空格..
-
也许看看,在设置中,DJANGO_SETTINGS_MODULE 是否被正确定义。或尝试在文档开头调用 settings.configure()。
标签: python django python-3.4 django-1.8