DJANGO_SETTINGS_MODULE
When you use Django, you have to tell it which settings you're using. Do this by using an environment variable, DJANGO_SETTINGS_MODULE
. The value of DJANGO_SETTINGS_MODULE
should be in Python path syntax, for example, mysite.settings
.
The django-admin utility
When using django-admin
, you can either set the environment variable once, or explicitly pass in the settings module each time you run the utility. Example (Unix Bash shell):
export DJANGO_SETTINGS_MODULE=mysite.settings
django-admin runserver
Example (Windows shell):
set DJANGO_SETTINGS_MODULE=mysite.settings
django-admin runserver
Use the --settings
command-line argument to specify the settings manually:
django-admin runserver --settings=mysite.settings
On the server ...
Get Mastering Django: Core now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.