Need help whit DJANGO_SETTINGS_MODULE

1,585 views
Skip to first unread message

Ilie Ioana

unread,
Apr 19, 2020, 1:22:25 PM4/19/20
to Django users
Hi,I'm new with django and python.
I just strated a new django project in a venv using django 3.0 and seems that DJANGO_SETTINGS_MODULE is not set when running django-admin runserver

Enter code here.(test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ django-admin runserver
Traceback (most recent call last):
  File "/home/ioana.i/Workspace/Ioana/test1/bin/django-admin", line 8, in <module>
    sys.exit(execute_from_command_line())
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
    super().execute(*args, **options)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 67, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py", line 61, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
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 tried to set it myself with export DJANGO_SETTINGS_MODULE=test1.settings but i receive  ModuleNotFoundError: No module named 'test1'
Seems like test1 module is not in the path, shouldn't be automatically added there?

(test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ django-admin shell
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sys
>>> sys.path
['/home/ioana.i/Workspace/Ioana/test1/bin', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages']
>>> 




Ayser shuhaib

unread,
Apr 19, 2020, 1:35:11 PM4/19/20
to django...@googlegroups.com
to run the server use:
Python manage.py runserver

It would be better if you send a picture of the project files structure.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07386bda-38a4-4897-b428-c8a39e52c487%40googlegroups.com.

Ilie Ioana

unread,
Apr 19, 2020, 1:39:50 PM4/19/20
to Django users
The project structure:


(test1) ioana.i@ioana-spamexperts:~/Workspace/Ioana/test1/test1$ tree
.
├── manage.py
└── test1
    ├── asgi.py
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py



:~/Workspace/Ioana/test1/test1$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
    super().execute(*args, **options)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 67, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/home/ioana.i/Workspace/Ioana/test1/lib/python3.6/site-packages/django/conf/__init__.py", line 61, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
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.

To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Ilie Ioana

unread,
Apr 19, 2020, 1:49:11 PM4/19/20
to Django users
After resetting the pc it worked.
Thanks.

Ayser shuhaib

unread,
Apr 20, 2020, 3:47:07 PM4/20/20
to django...@googlegroups.com
Great 👍🏻

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/50786ace-6ac3-4a95-86f9-2d241a4f4988%40googlegroups.com.

Raja Sekar Sambath

unread,
Apr 24, 2020, 12:33:49 PM4/24/20
to django...@googlegroups.com
could you share the solution here....
resetting PC didn't making any sense to me....

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/50786ace-6ac3-4a95-86f9-2d241a4f4988%40googlegroups.com.


--
Thanks & Regards,

Raja Sekar Sampath

DANIEL URBANO DE LA RUA

unread,
Apr 24, 2020, 1:00:56 PM4/24/20
to Django users
are you using virtual environment?

Raja Sekar Sambath

unread,
Apr 24, 2020, 1:16:17 PM4/24/20
to django...@googlegroups.com

Amitesh Sahay

unread,
Apr 24, 2020, 1:29:50 PM4/24/20
to django...@googlegroups.com
DJANGO_SETTINGS_MODULE is not the problem I guess, as its not there even in my settings.py. Did you define your app in apps settings? 

Regards,
Amitesh


Sunday Iyanu Ajayi

unread,
May 3, 2020, 9:32:57 PM5/3/20
to django...@googlegroups.com
Hi Ilie Ioana,
Please check if 
1. You are in your current directory ( or virtual evironment)
2. Is django installed on yur pc?

AJAYI Sunday 


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages