I was just wondering if anyone can clarify the best / most common way of setting the ‘django_settings_module’ setting when deploying to different environments (e.g. Heroku).
I’ve set up my project with separate ‘settings’ files for different environments. Looking at various tutorials, it seems like the simplest way of doing this was to add a ‘settings’ module to my project folder. I’ve then got a ‘base.py’ file containing all common settings, then separate settings files per environment that each import the base settings. All pretty standard. Nothing special.
My structure now looks like this:
django_project/ settings/ - __init__.py - base.py - development.py - production.py - testing.py - __init__.py - asgi.py - urls.py - wsgi.py
The thing is I’m not quite sure how to set the ‘django_settings_module’ path in my wsgi.py and manage.py files depending on which environment I’m deploying to. At the moment they look like this:
def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings.development')
Obviously I could manually type in this value myself just before deploying to each new environment (e.g. changing ‘development’ to ‘production’ just before deploying to Heroku). However that doesn’t feel right. Surely there’s a more robust and repeatable process than that?
Many thanks in advance for your help.
All the best,