[Fixed]-Am I supposed to create a file use .env or os.py to store my secret key

1👍

Since you are hosting on Heroku, you shouldn’t manually create file on your server to store the SECRET_KEY, since it will be deleted on server restart. I would use Heroku environment variables, which can be set from your command line:

heroku config:set SECRET_KEY=some_very_secret_key

You can then easily read it in your Django settings:

os.environ['SECRET_KEY']

For more details see: https://devcenter.heroku.com/articles/config-vars

Leave a comment