Skip to main content

django-configurator Latest version on PyPI

Build Status Test coverage status Documentation status Supported Python versions Supported Django versions

django-configurator eases Django project configuration by relying on the composability of Python classes. It extends the notion of Django’s module based settings loading with well established object oriented programming patterns. This is a port of the django-configurations project which is no longer supported. To replace django-configurations with this project, search and replace all occurrences of “configurations” with “dj_configurator” in your project that you were using django-configurations.

Check out the documentation for more complete examples.

Quickstart

Install django-configurator:

$ python -m pip install django-configurator

or, alternatively, if you want to use URL-based values:

$ python -m pip install django-configurator[cache,database,email,search]

Then subclass the included dj_configurator.Configuration class in your project’s settings.py or any other module you’re using to store the settings constants, e.g.:

# mysite/settings.py

from dj_configurator import Configuration

class Dev(Configuration):
    DEBUG = True

Set the DJANGO_CONFIGURATION environment variable to the name of the class you just created, e.g. in bash:

$ export DJANGO_CONFIGURATION=Dev

and the DJANGO_SETTINGS_MODULE environment variable to the module import path as usual, e.g. in bash:

$ export DJANGO_SETTINGS_MODULE=mysite.settings

Alternatively supply the --configuration option when using Django management commands along the lines of Django’s default --settings command line option, e.g.

$ python -m manage runserver --settings=mysite.settings --configuration=Dev

To enable Django to use your configuration you now have to modify your manage.py, wsgi.py or asgi.py script to use django-configurator’s versions of the appropriate starter functions, e.g. a typical manage.py using django-configurator would look like this:

#!/usr/bin/env python

import os
import sys

if __name__ == "__main__":
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
    os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')

    from dj_configurator.management import execute_from_command_line

    execute_from_command_line(sys.argv)

Notice in line 10 we don’t use the common tool django.core.management.execute_from_command_line but instead dj_configurator.management.execute_from_command_line.

The same applies to your wsgi.py file, e.g.:

import os

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')

from dj_configurator.wsgi import get_wsgi_application

application = get_wsgi_application()

Here we don’t use the default django.core.wsgi.get_wsgi_application function but instead dj_configurator.wsgi.get_wsgi_application.

Or if you are not serving your app via WSGI but ASGI instead, you need to modify your asgi.py file too.:

import os

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')

from dj_configurator.asgi import get_asgi_application

application = get_asgi_application()

That’s it! You can now use your project with manage.py and your favorite WSGI/ASGI enabled server.

Metadata

Release files for django-configurator 1.3.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 django-configurator 1.3.1
File Size Uploaded Provenance Actions
django_configurator-1.3.1.tar.gz 13.9 kB Without provenance Details for django_configurator-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-configurator 1.3.1
File Interpreter ABI Platform Actions
django_configurator-1.3.1-py3-none-any.whl Python 3 none any Details for django_configurator-1.3.1-py3-none-any.whl

Total release size: 30.0 kB

Release files / django_configurator-1.3.1.tar.gz

Download URL django_configurator-1.3.1.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f8596f6854dda0d543b4d07adcc64dfffa8249f7374e6b06b4004de370e9863b
BLAKE2b-256 checksum
How to use checksums
3717b48defaff9ac19237cf51e8b5b5c77da118352c2ad1fe9e1fac1d49e5e29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.11

Release files / django_configurator-1.3.1-py3-none-any.whl

Download URL django_configurator-1.3.1-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3c07c9efac2a59d637b0736b45fc44250f5a93fd94f882b7317d2bf344d961f
BLAKE2b-256 checksum
How to use checksums
a49df5f68921379df0630cb1613f276245644f173f12385aa0c8ba2afa551c4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.11

Security for django-configurator 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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