This is how my settings.py looks like:
import os
import dotenv
dotenv_file = os.path.join(BASE_DIR, ".env")
if os.path.isfile(dotenv_file):
dotenv.load_dotenv(dotenv_file)
# UPDATE secret key
SECRET_KEY = os.environ['SECRET_KEY']
This is how my .env file looks like:
SECRET_KEY="TOPSECRETKEY"
When running python manage.py migrate, it returns KeyError: 'SECRET_KEY'
I figured it out, (for future reference) My .env file was in the same folder as settings.py and it needed to be in the same folder as manage.py