dj-database-url
Use Database URLs in your Django Application.
Decision gist · record as of 2026-08-14
Yes. This is a stable, actively maintained utility with zero known vulnerabilities, low install friction, and broad database backend support. It directly solves the common problem of externalizing database configuration in Django applications and is widely used in containerized and cloud-deployed environments. Install it if you use Django and want to follow 12factor principles for database configuration.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires DATABASE_URL environment variable to be set, or a default URL passed to config(); special characters in URLs must be percent-encoded.
- Low friction: single dependency on django, wheel-only distribution, actively maintained with recent commits.
- Supports current Python versions (3.10–3.14) and Django 4.2 through 6.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause (permissive): you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2026-02-19 (176 days) · last repo commit 2026-08-10 · 1,572 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 8,506,063 downloads/mo, #1,617 on PyPI
Alternatives
Verify before relying
import dj_database_url
DATABASES = {
'default': dj_database_url.config(
conn_max_age=600,
conn_health_checks=True,
)
}- Whether custom backend registration persists across application reloads or requires per-request setup.
- Performance impact of connection health checks on request latency in high-throughput scenarios.
What it is and what it does
dj-database-url is a lightweight utility that converts DATABASE_URL environment variables into Django database configuration dictionaries. It implements the 12factor pattern for backing services, allowing you to externalize database connection details into environment variables rather than hardcoding them in settings.py. The package handles URL parsing for multiple database engines—PostgreSQL, MySQL, Oracle, SQLite, PostGIS, Redshift, CockroachDB, Timescale, and others—and automatically maps them to the correct Django backend.
The main entry points are config() (reads from DATABASE_URL environment variable with optional fallback) and parse() (accepts a URL string directly). Both return a Django DATABASES dictionary entry. The package also supports Django's connection pooling via conn_max_age and health checks via conn_health_checks, and allows registration of custom database backends with optional post-processing functions for non-standard configuration needs.
Use it for
- Containerized deployments where database credentials are injected via environment variables at runtime.
- Multi-environment setups (dev, staging, production) using the same code with different DATABASE_URL values.
- Enabling connection pooling and health checks in Django without manual DATABASES dictionary construction.
- Supporting non-standard or custom database backends by registering them with dj_database_url.register().
- Migrating from hardcoded database settings to environment-driven configuration in existing Django projects.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a stable, actively maintained utility with zero known vulnerabilities, low install friction, and broad database backend support. It directly solves the common problem of externalizing database configuration in Django applications and is widely used in containerized and cloud-deployed environments. Install it if you use Django and want to follow 12factor principles for database configuration.
Install
dj-database-url on PyPI
Before you install
Low friction: single dependency on django, wheel-only distribution, actively maintained with recent commits. Supports current Python versions (3.10–3.14) and Django 4.2 through 6.
Requires DATABASE_URL environment variable to be set, or a default URL passed to config(); special characters in URLs must be percent-encoded.
License in practice
BSD-3-Clause (permissive): you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
import dj_database_url
DATABASES = {
'default': dj_database_url.config(
conn_max_age=600,
conn_health_checks=True,
)
}
Verify before relying
- Whether custom backend registration persists across application reloads or requires per-request setup.
- Performance impact of connection health checks on request latency in high-throughput scenarios.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagedjango |
| Maintenance | Actively maintained 176 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,506,063 / month, #1,617 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Environment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development :: Libraries :: Python Modules |
Evidence: dj_database_url-3.1.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django database url environment variable”
- dj-database-urlParses DATABASE_URL environment variables into Django database…
- django-environLoads and parses environment variables from .env files to configure…
- django-cache-urlConfigures Django cache backends from environment variables using the…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also django-db-connection-pool · dsnparse · django-db-geventpool · dbt-copilot-python · django-heroku · django-snowflake · mssql-django · sqlalchemy-jdbcapi · databases · django-pg-returning