13👍
✅
I think you are trying this locally, and don’t have the SECRET_KEY
setup in your environment.
Set it using
export SECRET_KEY="somesecretvalue"
and then running python manage.py shell --settings=entri.settings.prod
should work fine.
2👍
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
- Git push heroku master: Heroku push rejected, no Cedar-supported app detected
- South migrate error: name 'UUID' is not defined
- DateTimeField received a naive datetime while time zone support is active
- How does django convert string to modules?
0👍
In Django while trying to secure/hide my secret_key, my problem was even after setting the secret_key using the set command on windows, I still got a ‘Key must not be empty’ error. I solved that by removing all the spaces before and after the assignment operator in the command. In your cmd, write
set SECRET_KEY="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"
instead of
set SECRET_KEY = "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"
Source:stackexchange.com