X
X
xxx2017-09-03 13:26:22
Django
xxx, 2017-09-03 13:26:22

Where to define DJANGO_SETTINGS_MODULE?

The DJANGO_SETTINGS_MODULE environment variable is defined by default in two django project files, namely manage.py and wsgi.py. At some points, it needs to be defined in settings.py , how to do it, and most importantly, why?
"The DJANGO_SETTINGS_MODULE value must contain the Python import path, such as mysite.settings."
I had a problem deploying to pythonanywhere after changing this variable in manage.py and wsgi.py. I changed the name of the project folder in which settings.py is located to config and registered the same path in manage.py and wsgi.py, respectively changing the variables in settings.py along the way. Further, when setting up the wsgi file of the server, I registered the same paths,

os.environ['DJANGO_SETTINGS_MODULE'] = 'config.settings'

After restarting the server in the error log the following
Error running WSGI application
ImportError: No module named config.settings

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-09-03
@kentuck1213

os.environ['DJANGO_SETTINGS_MODULE'] = 'config.settings'
where config should be the name of the project.
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project_name.settings'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question