Forums

Django app settings.py file can't see my new environment variables

[question satisfied]

Hi jpark,

Your best bet for introducing an environment variable into your web app is to set it in your wsgi file (available on the web tab). something like this:

import os
os.environ['SECRET_KEY'] = 'sekrit!'

re: the bashrc not being loaded when you hit 'save and run', that is unexpected. It may be a bug -- I'll take a look at the save+run code... IN the meantime, your best bet might be to work inside a "Bash" console, started from the consoles page, and run your scripts from there?

I do not have the option to 'save and run' the .bashrc file through the 'files' tab in my dashboard.

Hi Jared, I was suggesting you open a Bash console by going to the consoles bash and clicking the "Bash" option. That should load a console with your .bashrc loaded, inside which you'll then be able to run python scripts from the command-line...

For anyone else with this problem, I've tried to write up a quick guide to setting up environment variables: https://help.pythonanywhere.com/pages/environment-variables-for-web-apps