Skip to main content
https://secure.travis-ci.org/julianwachholz/dj-config-url.png?branch=master

This simple Django utility allows you to utilize 12factor inspired environment variables to configure your Django application.

This project has been forked from kennethreitz’ dj-database-url and is fully compatible with it, so you can use this utility as a drop-in replacement.

Supported configuration

Support currently exists for the following database engines: PostgreSQL, PostGIS, MySQL, MySQL (GIS) and SQLite.

You can also configure your CACHES configuration for the backends supported by the Django core: Database, dummy, file based, local memory as well as both Memcached backends.

Installation

Installation is simple:

$ pip install dj-config-url

Usage

Configure your database in settings.py from DATABASE_URL:

DATABASES = {'default': dj_config_url.config()}

Parse an arbitrary Database URL:

DATABASES = {'default': dj_config_url.parse('postgres://...')}

Configure your cache backend:

CACHES = {'default': dj_config_url.parse('memcache://...')}

Use a custom cache backend class:

CACHES = {'default': dj_config_url.parse('memcache://127.0.0.1:123?password=s3cr3t', 'redis_cache.cache.RedisCache')}

Database examples

Engine

Django Backend

URL

PostgreSQL

django.db.backends.postgresql_psycopg2

postgres://USER:PASSWORD@HOST:PORT/NAME

PostGIS

django.contrib.gis.db.backends.postgis

postgis://USER:PASSWORD@HOST:PORT/NAME

MySQL

django.db.backends.mysql

mysql://USER:PASSWORD@HOST:PORT/NAME

MySQL (GIS)

django.contrib.gis.db.backends.mysql

mysqlgis://USER:PASSWORD@HOST:PORT/NAME

SQLite

django.db.backends.sqlite3

sqlite:///PATH [1]

Cache examples

Backend

Django Backend

URL

Database

django.core.cache.backends.db.DatabaseCache

dbcache://table_name

Dummy

django.core.cache.backends.dummy.DummyCache

dummycache://

File based

django.core.cache.backends.filebased.FileBasedCache

filecache:///path/to/cache

Local Memory

django.core.cache.backends.locmem.LocMemCache

locmemcache://[optional name]

Memcached

django.core.cache.backends.memcached.MemcachedCache

memcache://IP:PORT[,IP:PORT, ...]

PyLibMC

django.core.cache.backends.memcached.PyLibMCCache

pymemcache://IP:PORT[,IP:PORT, ...]

You may specify options for the cache backends as query parameters in the url, e.g.:

CACHES = {
    'default': dj_config_url.parse('filecache:///var/tmp/django_cache?timeout=60&max_entries=1000&cull_frequency=2'),
}

This will be equivalent of writing this in your settings.py:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/tmp/django_cache',
        'TIMEOUT': 60,
        'OPTIONS': {
            'MAX_ENTRIES': 1000,
            'CULL_FREQUENCY': 2,
        }
    }
}

Metadata

Release files for dj-config-url 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dj-config-url 0.1.1
File Size Uploaded
dj-config-url-0.1.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj-config-url 0.1.1
File Interpreter ABI Platform
dj_config_url-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.5 kB

Release files / dj-config-url-0.1.1.tar.gz

Download URL dj-config-url-0.1.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
32b87c85f6359a6a772bd8d5e131640529c4addfc2069918f4eaa8de8ecbb548
BLAKE2b-256 checksum
How to use checksums
d7bea19b45afb8a624b2b3258672fb3e97c1620e5e18d5c0a64ca8886f1825e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dj_config_url-0.1.1-py2.py3-none-any.whl

Download URL dj_config_url-0.1.1-py2.py3-none-any.whl
Size 7.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8c411dca3ead2b64786c9ae735ef3085518ff92a79e98e441953b26c47063e3f
BLAKE2b-256 checksum
How to use checksums
863f2c30720784ce280cd5f332a5bba0d568d4620285d5daf654df04b80c0fce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page