When i try to use "django-admin runserver" on a project that worked about a month ago (i didnt edit anything btw) this happened (on VSCode)

PS F:\filenaem\djangler> django-admin runserver     
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Scripts\django-admin.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\commands\runserver.py", line 75, in execute
    super().execute(*args, **options)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\commands\runserver.py", line 82, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
           ^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\conf\__init__.py", line 81, in __getattr__
    self._setup(name)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\conf\__init__.py", line 61, 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.

tried to use the django-admin runserver command and expected it to work, because its a finished project that i made with the assistance of my old teacher, but for whatever reason when i try to run it now 2 months later and after moving it to another computer via an external disk it doesnt work, any help?

also "python manage.py runserver" doesnt work eighter, it just gives me this:

PS F:\filenaem\djangler> python manage.py runserver
C:\Users\user\AppData\Local\Programs\Python\Python312\python.exe: can't open file 'F:\\filenaem\\djangler\\manage.py': [Errno 2] No such file or directory

When 'moving' Django projects, take care because each project has its list of installed packages which is available on the requirements.txt. Those packages are usually contained in a virtual environment if one is used.

I'm guessing you haven't activated your virtual environment. If you don't have access to the virtual environment, you may want to create a new one and install the packages in your requirements.txt by running pip install -r requirements.txt. If you can use your virtual environment, you can activate it using yourvirtualenvironmentname\Scripts\activate.

Вернуться на верх