Django. Using multiple settings files with Heroku

You can use the environment variable DJANGO_SETTINGS_MODULE to specify a default settings module:

https://docs.djangoproject.com/en/dev/topics/settings/#envvar-DJANGO_SETTINGS_MODULE

On local Linux machine:

export DJANGO_SETTINGS_MODULE=settings.local

On Heroku:

heroku config:set DJANGO_SETTINGS_MODULE=settings.production

After you have logged into heroku with heroku login you can check your configs by running: heroku config. If you dont see a SECRET_KEY and DJANGO_SETTINGS_MODULE you can set them by running:

heroku config:set SECRET_KEY='secret_key_goes_here'

and

heroku config:set DJANGO_SETTINGS_MODULE=mysite.settings.production

Finally, make sure that you have the following syntax inside of your production setting file:

SECRET_KEY = os.environ['SECRET_KEY']

The above intstructions are for the following project structure

-myproject
  -app1
  -app2
  -mysite
    -settings
      __init__.py
      base.py
      dev.py
      production.py
-manage.py
-Pipfile
-Procfile
-requirements.txt