I'm forced to keep my .env
file in a non-standard path outside the root of my project (in a separate directory altogether).
Let's say I have my Django project in /var/projects/my_project
, though I have my .env
file in /opt/envs/my-project/.env
where my SECRET_KEY
is stored. In my settings.py
file, I'd like to explicitly use the .env
file at that path so that I can still do this:
from decouple import config
secret_key = config('SECRET_KEY')
I figured it out.
Instead of importing
decouple.config
and doing the usualconfig('FOOBAR')
, create a newdecouple.Config
object usingRepositoryEnv('/path/to/env-file')
.Hopefully this helps someone.