I changed my secret key to an environment variable on my Heroku app. I changed it because I found out that keeping the secret key in settings.py
was a security
You can export your secret key as an environment variable locally.
export SECRET_KEY=mysecretkey
./manage.py runserver
Or you could change your settings.py
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
if DEBUG:
SECRET_KEY = 'mysecretkey'
else:
SECRET_KEY = os.environ['SECRET_KEY']