0

I keep getting an Improperly Configured Error when I try to run my server

Error message:

django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I created a new django project, I have django installed in my virtual environment, I did not forget to activate the virtual environment, And I triple checked my python path, Here is the full traceback:

(venv3) C:\Users\user\Desktop\trialproject>django-admin.py runserver
Traceback (most recent call last):
  File "C:\Users\user\Desktop\trialproject\venv3\Scripts\django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
    super().execute(*args, **options)
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\core\management\base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\core\management\commands\runserver.py", line 67, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
    self._setup(name)
  File "c:\users\user\desktop\trialproject\venv3\lib\site-packages\django\conf\__init__.py", line 57, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Someone please help me figure out the problem. Thanks

1 Answers1

0

that usually happen when you want to run your server with wrong virtual environment. make sure you have the right virtual environment and try this :

python manage.py runserver

UPDATE : check if this is useful for you

babak gholamirad
  • 407
  • 4
  • 10