caluma
caluma copied to clipboard
Document settings import when using Caluma with django-environ / env files
Caluma uses django-environ with a .env
file in the project root. When using Caluma as an app, it will most likely be installed as a package. Then, the settings will look for the .env
file relative to Caluma's location, not the project root.
django-environ reads the env vile and puts it in the process's environment variables.
Now, if your project used .env
as well and write your settings file as it's documented ...
import environ
from caluma.settings.caluma import * # noqa
env = environ.Env()
ROOT_DIR = environ.Path(__file__) - 2
ENV_FILE = env.str("DJANGO_ENV_FILE", default=ROOT_DIR(".env"))
if os.path.exists(ENV_FILE): # pragma: no cover
environ.Env.read_env(ENV_FILE)
What now happens is that the caluma settings are imported before django-environ reads the file; therefore Caluma won't have all it's settings set.
The correct way to do it would be to move the caluma settings import to below the read_env()
call.