I'm trying to use python-dotenv to run the .env file when running ./manage.py shell.
But .env isn't run when I start shell. Nothing different than normal happens.
What I've done:
- installed
python-dotenvwithpip install python-dotenvin my virtual environment - added a
.envfile in the same directory as my projectsettings.py
Also added below to settings.py:
from dotenv import load_dotenv
load_dotenv()
For context, my .env looks like:
export PYTHONSTARTUP=`pwd`/.pythonrc.py
echo "environment variables set"
And I'm exporting .pythonrc.py so I can do some imports when shell is loaded.
I'm pretty new to django. Am I missing something obvious?