Forums

environment variables

For my Django development I changed the SECRET_KEY and database settings to call the environment variables as described here. So for my setup I have

WSGI configuration file:

os.environ['MY_SECRET_KEY'] = 'secretkey'

in home/user/.virtualenvs/env/bin/postactivate

export MY_SECRET_KEY="secretkey"

and in my settings.py Django file

SECRET_KEY = os.environ['MY_SECRET_KEY']

Whenever I 'Start a console in this virtualenv' and try and use a manage.py command it gives me a KeyError: SECRET_KEY message. If i type export from that console it should list the exports I set up in home/user/.virtualenvs/env/bin/postactivate correct? It currently does not. Any advice?

At the moment, postactivate is not executed when you start the virtualenv console from the web app tab. We have a fix that will be deployed the next time we update PythonAnywhere.