django-environ
A package that allows you to utilize 12factor inspired environment variables to configure your Django application.
What it is and what it does
django-environ bridges environment variables and Django settings by reading .env files and parsing their contents into typed Python objects. It implements the Twelve-Factor methodology, which treats configuration as environment-provided data rather than code, eliminating the need for multiple settings files per deployment environment.
The package handles three main tasks: loading variables from .env files into os.environ, casting string values to Python types (bool, int, list, etc.), and parsing connection URL strings (database, cache, email) into Django-compatible configuration dictionaries. It raises Django's ImproperlyConfigured exception when required variables are missing, catching configuration errors early. The single runtime dependency is typing_extensions, and it supports Python 3.9 through 3.14 across Django versions 2.2 to 6.0.
Use it for:
- Store database credentials and URLs in .env files without committing them to version control
- Switch between development, staging, and production configurations by changing environment variables
- Parse Redis and cache URLs into Django CACHES configuration dictionaries
- Enable Docker deployments using file-based secrets mounted as environment variables
- Centralize Django settings configuration in a single file instead of maintaining multiple settings_*.py variants
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Loads and parses environment variables from .env files to configure Django applications using Twelve-Factor methodology, with support for type casting and URL-based connection strings.
Yes. django-environ is production-stable, actively maintained, has no known vulnerabilities, minimal install friction, and solves a standard Django configuration problem. It is widely adopted (top 5000 PyPI packages) and supports current Django and Python versions. Install it if you use Django and want environment-based configuration following industry best practices.
Install
django-environ on PyPI
pip
pip install django-environuv
uv add django-environpoetry
poetry add django-environInstalling django-environ
Before you install
Low friction installation with a single runtime dependency (typing_extensions). Active maintenance with a recent release 57 days ago and consistent commit activity; classifiers indicate production-stable status and support across Django 2.2 through 6.0.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects without licensing concerns.
Quickstart
pip install django-environ
import environ
import os
env = environ.Env(DEBUG=(bool, False))
environ.Env.read_env('.env')
DEBUG = env('DEBUG')
DATABASES = {'default': env.db()}
Requires Python 3.9 or later; Django 2.2+ for full compatibility.
Verify before relying
- Performance characteristics when handling large numbers of environment variables or complex .env files
- Specific behavior differences between Env and FileAwareEnv for Docker-style file-based secrets
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 57 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,557,519/month — #1,606 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_environ-0.14.0-py3-none-any.whl
Keywords: environment, django, variables, 12factor
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-cache-urlConfigures Django cache backends from…
permissive · top 15,000 on PyPI
django-constanceDjango-constance lets you store and manage…
permissive · top 5,000 on PyPI
django-split-settingsSplits Django settings across multiple files…
permissive · top 15,000 on PyPI
python-decoupleReads configuration parameters from environment…
permissive · top 5,000 on PyPI
envparseParses environment variables with optional type…
permissive · top 15,000 on PyPI
dj-email-urlConfigures Django email backends from…
permissive · top 15,000 on PyPI
python-dotenvReads key-value pairs from a .env file and sets…
permissive · top 100 on PyPI
dj-database-urlParses DATABASE_URL environment variables into…
permissive · top 5,000 on PyPI
tempenvTemporarily override environment variables…
permissive · top 15,000 on PyPI
django-decorator-includeApplies decorators to Django URL patterns…
permissive · top 15,000 on PyPI