getting raise KeyError(key) KeyError: 'SECRET_KEY' with django on production settings

后端 未结 2 1721
长情又很酷
长情又很酷 2021-02-20 07:10

I\'ve 2 separate settings files for production and development and a common base.py settings file
base.py

SECRET_KEY = r\"!@#$%^&12345         


        
2条回答
  •  庸人自扰
    2021-02-20 08:06

    I use os.getenv('SECRET_KEY'), instead of os.environ['SECRET_KEY']

    print os.getenv('SECRET_KEY')    #returns None if KEY doesn't exist
    print os.getenv('SECRET_KEY', 0) #will return 0 if KEY doesn't exist 
    

    my python version is 2.7.12

提交回复
热议问题