Reputation: 2292
I deployed my Django-project via Apache2 on a server.
The problem I have is that I have two setting-modules: settings.py
which are my local development settings and settingsprod.py
which are my productive settings.
I found the following line in the WSGI.py:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
Is this module only called when using WSGI? And if yes is this a good place to use my production settings like so?
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settingsprod")
For local development I use the development server like so:
python3 manage.py runserver
Does this still defaults to settings.py then?
Upvotes: 0
Views: 517
Reputation: 1357
Yes, your setup works as expected. Though if you use extra tools like celery, you might need to also specify the settingsprod
for those setups aswell.
The way I handle such a situation is exactly the other way around: I use settings.py
for my production settings and have an additional settings_development.py
that I use for all development tasks. This way I don't have to remember setting the production settings in all production relevant files, but instead simply use the development settings for development like so:
python3 manage.py runserver --settings=proj.settings_development
If you often use manage.py commands and want to save some time typing, you can make a copy of your manage.py
e.g. as manage_dev.py
and change the settings module line like so:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings_development")
and then call your manage functions with:
python3 manage_dev.py runserver
Upvotes: 3