0

Recently finished my app and I am ready to deploy it but I don't understand how to set the application's SECRET_KEY. I'm trying to change my database from sqlite to postgresql, but I get the following error:

raise KeyError(key) from None KeyError: 'SECRET_KEY'

development.py

from nurs_course.settings.common import *

ALLOWED_HOSTS = ['0.0.0.0', 'localhost']

SECRET_KEY = '9t*re^fdqd%-o_&zsu25(!@kcbk*k=6vebh(d*9r)+j8w%7ci1'

DEBUG = True

production.py

from nurs_course.settings.common import *

DEBUG = False

SECRET_KEY = os.environ['SECRET_KEY']

# SECURITY WARNING: update this when you have the production host
ALLOWED_HOSTS = ['0.0.0.0', 'localhost']

common.py has all the other settings required. I use Windows OS w/ Powershell. I've been stuck on this for a bit and I am just unsure how to set the SECRET_KEY properly. Any help would be appreciated!

skoleosho97
  • 173
  • 1
  • 2
  • 13

2 Answers2

0

As given here.

If you're using a virtual environment, you might want to activate it and run this code:

export SECRET_KEY='9t*re^fdqd%-o_&zsu25(!@kcbk*k=6vebh(d*9r)+j8w%7ci1'

After that run python manage.py shell --settings=entri.settings.prod

0

You have to export SECRET_KEY in the following way,

export SECRET_KEY="somesecretvalue"

If you are using Python 2.x, try:

os.getenv('SECRET_KEY')
код е
  • 196
  • 2
  • 11