Search code examples
docker-composecookiecutter-django

Maintaining DJANGO_SETTINGS_MODULE between local and production environments


Running into an issue when we deployed to production, had to update manage.py to set os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") to config.settings.production. Of course this broke local settings when we pulled back to our dev branch.

We're running our containers via the docker-compose local.yml commands recommended in the documentation.

Am I missing something? Is this by design?


Solution

  • This environment variable should be set via a .env file, the production one is located under .envs/.production/.django, and is not in source control (for security reasons). So yes, it is by design.

    Depending on how you start your server, this file might be missing and the environment will end up unset.