Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Configuration models for Django allowing config management with auditing.

Project description

Part of edX code.

django-config-models Travis Codecov

Overview

This app allows other apps to easily define a configuration model that can be hooked into the admin site to allow configuration management with auditing.

Installation

Add config_models to your INSTALLED_APPS list.

Usage

Create a subclass of ConfigurationModel, with fields for each value that needs to be configured:

class MyConfiguration(ConfigurationModel):
    frobble_timeout = IntField(default=10)
    frazzle_target = TextField(defalut="debug")

This is a normal django model, so it must be synced and migrated as usual.

The default values for the fields in the ConfigurationModel will be used if no configuration has yet been created.

Register that class with the Admin site, using the ConfigurationAdminModel:

from django.contrib import admin

from config_models.admin import ConfigurationModelAdmin

admin.site.register(MyConfiguration, ConfigurationModelAdmin)

Use the configuration in your code:

def my_view(self, request):
    config = MyConfiguration.current()
    fire_the_missiles(config.frazzle_target, timeout=config.frobble_timeout)

Use the admin site to add new configuration entries. The most recently created entry is considered to be current.

Configuration

The current ConfigurationModel will be cached in the configuration django cache, or in the default cache if configuration doesn’t exist. The configuration and default caches are specified in the django CACHES setting. The caching can be per-process, per-machine, per-cluster, or some other strategy, depending on the cache configuration.

You can specify the cache timeout in each ConfigurationModel by setting the cache_timeout property.

You can change the name of the cache key used by the ConfigurationModel by overriding the cache_key_name function.

Extension

ConfigurationModels are just django models, so they can be extended with new fields and migrated as usual. Newly added fields must have default values and should be nullable, so that rollbacks to old versions of configuration work correctly.

Documentation

The full documentation is at https://config_models.readthedocs.org.

License

The code in this repository is licensed under the AGPL 3.0 unless otherwise noted.

Please see LICENSE.txt for details.

How To Contribute

Contributions are very welcome.

Please read How To Contribute for details.

Even though they were written with edx-platform in mind, the guidelines should be followed for Open edX code in general.

Reporting Security Issues

Please do not report security issues in public. Please email security@edx.org.

Mailing List and IRC Channel

You can discuss this code in the edx-code Google Group or in the #edx-code IRC channel on Freenode.

Change Log

Unreleased

[0.1.10] - 2018-05-21

Changed

  • Don’t assume the user model is Django’s default auth.User

[0.1.9] - 2017-08-07

Changed

  • Updated Django REST Framework dependency to 3.6 as we were not actually compatible with 3.2.

[0.1.8] - 2017-06-19

Added

  • Support for Django 1.11.

[0.1.7] - 2017-06-19

  • Unreleased version number

[0.1.6] - 2017-06-01

Added

  • Support for Django 1.10.

[0.1.1] - [0.1.5] - 2017-06-01

Added

  • Add quality testing to travis run.
  • Add encrypted password for package PyPI.

Removed

  • Remove the quality condition on deployment.
  • Remove the version combos known to fail.

Changed

  • Allow for lower versions of djangorestframework, to be compatible with edx-platform.
  • Constrict DRF to version that works.
  • Update versions of requirements via pip-compile.
  • Use different test target - test-all instead of validate.

Fixed

  • Fix name and supported versions.

[0.1.0] - 2016-10-06

Added

  • First release on PyPI.

Project details


Release history Release notifications

This version
History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.6

History Node

0.1.5

History Node

0.1.3

History Node

0.1.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django_config_models-0.1.10-py2.py3-none-any.whl (24.9 kB) Copy SHA256 hash SHA256 Wheel py2.py3 May 29, 2018
django-config-models-0.1.10.tar.gz (34.2 kB) Copy SHA256 hash SHA256 Source None May 29, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page