Coder Social home page Coder Social logo

strogo / django-config-models Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openedx/django-config-models

0.0 1.0 0.0 445 KB

Configuration models for Django allowing config management with auditing.

License: GNU Affero General Public License v3.0

Makefile 4.78% Python 94.39% HTML 0.83%

django-config-models's Introduction

Part of edX code.

django-config-models CI_ 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 [email protected].

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.

django-config-models's People

Contributors

edx-requirements-bot avatar feanil avatar usamasadiq avatar mraarif avatar bmedx avatar jawayria avatar awais786 avatar cpennington avatar robrap avatar jmbowman avatar azarembok avatar kdmccormick avatar mikix avatar iamsobanjaved avatar regisb avatar timmc-edx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.