Skip to main content

Django Configuration

Some site wide settings belong in the database. This Django-Configure provides a familiar way to implement this pattern. It uses django-polymorphic, mostly to provide a clean admin interface. Any model field can be used in a configuration, and any of the standard django admin utilities (like permissions) can be used.

Installation

Install from pypi using your favorite method::

pip install django-configuration

Usage

In myapp/models.py::

from configuration.models import Configuration

class MyConfiguration(Configuration):
    my_var = models.CharField(max_length=255, default='Hello!')

Then elsewhere::

>>> from myapp.models import MyConfiguration
>>> print MyConfiguration.objects.get()
Hello!

A Configuration instance is not saved to the database until save is explicitly called or until it is saved in the admin, so it is important to specify default values on your fields.

A custom admin interface can be provided as follows::

from configuration.models import Configuration
from configuration.admin import ConfigurationAdmin

class MyAdmin(ConfigurationAdmin):
    pass

class MyConfiguration(Configuration):
    my_var = models.CharField(max_length=255, default='Hello!')

    admin_class = MyAdmin

The admin class must inherit from ConfigurationAdmin. The admin_class attribute can also be given as a dotted string::

class MyConfiguration(Configuration):
    my_var = models.CharField(max_length=255, default='Hello!')

    admin_class = 'myapp.admin.MyAdmin'

Efficiency and Caching

Django-Configuration is quick, easy and intuitive, and allows you to follow django patterns. However it is not the most efficient method of keeping configuration optinos in the database. The use of django-polymorphic allows for a great admin interface but makes queries more costly. The library currently provides no caching - although caching apps that cache query results should help with that.

Metadata

Release files for django-configuration 0.0.3

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-configuration 0.0.3
File Size Uploaded Provenance Actions
django-configuration-0.0.3.zip 8.5 kB Without provenance Details for django-configuration-0.0.3.zip

Release files / django-configuration-0.0.3.zip

Download URL django-configuration-0.0.3.zip
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a410b082a13dc9d67bcff8e39dd2365c747c09a8e400f65ea103e14fa949122d
BLAKE2b-256 checksum
How to use checksums
4b1b7536c246848031a9375562c9e3026ae12578a3c38c4462fb24e8d6955827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-configuration 0.0.3

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