0
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;
4

1 回答 1

0

验证您是否已正确添加路径变量并尝试使用命令

    django-admin startproject <project_name>

代替

   django-admin.py startproject <project_name>
于 2015-04-02T17:59:55.330 回答