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;
答案 0 :(得分:0)
验证您是否已正确添加路径变量并尝试使用命令
django-admin startproject <project_name>
而不是
django-admin.py startproject <project_name>