nothingness nothingness - 1 year ago 68
Python Question

I added a SECRET_KEY config variable to my Django app on Heroku but now it won't work locally

I changed my secret key to an environment variable on my Heroku app because that's bad but now locally it won't work.

I'm a few months into Django, and to programming period. I just found out deploying secret key to deployment was a security risk and changed it.

Now I want to develop locally but it will not work, how do I fix it?


You can export your secret key as an environment variable locally.

export SECRET_KEY=mysecretkey
./ runserver

Or you could change your to use a hardcoded secret key in DEBUG mode. If you do this, make sure you are running with DEBUG = False on Heroku.

import os

    SECRET_KEY = 'mysecretkey'
    SECRET_KEY = os.environ['SECRET_KEY']