DjEnv: Django + Environment

Load Django Settings Directly from Environmental Variables


  • modify django configuration without modifying source code
  • prevent hard-coding of Django settings
  • works great with Docker


with pip

pip install djenv

with pipenv

pipenv install djenv

basic usage

# inside

# import settings from environment
from djenv.settings import *

Prepend Settings with DJANGO_ to import them. For example:

DJANGO_DEBUG=False python3 runserver

Will set DEBUG=False in the

advanced usage

You can also replace nested settings like DATABASES by setting a JSON

DJANGO_DATABASES='{ "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite3" } }'  python3 runserver