python - Error setting environment variables -
I am working on a Django application. I want to enter SECRET_KEY in the environmental variable. I added it to the .bashrc file:
exported SECRET_KEY = sdfsjhsuresfsdf I used to source . Bashrc I am able to use environment variables from Python shell:
import os os.environ ['SECRET_KEY'] < / Pre> However, when I try to access it from the settings.py file it's a keyError what am I doing?
Try:
export SECRET_KEY = sdfsjhsuresfsdf Then start the source and a new Python example should look it up.
Bash does not always export its variable automatically.
Generally, OS environments variables are such a hard task that keep the configuration information trustworthy, because the issue. It is difficult to find out why the variables do not appear or not. Reading configuration information from configuration files (whether .ini, .json, or any other format) is a bit more robust but, environmental variables are usually used, therefore, when in Rome ...
Comments
Post a Comment