Skip to content

An application to allow for other apps to easily store site based configurations. This fork is to allow the key to be dynamically generated so that we can have multiple instances of each config and do interesting things with them, such as attaching them to a feinCMS page etc..

Notifications You must be signed in to change notification settings

hejsan/django-configstore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Config Store

  • Stores configurations and are retrievable as a dictionary
  • Configurations are lazily loaded and are cached per request
  • Configuration is defined as a django form

Installation

  1. Add the 'configstore' directory to your Python path
  2. Add 'configstore' to your INSTALLED_APPS in your settings file

Usage

Define your configuration form somewhere:

from django import forms
from django.contrib.auth.models import User

from configstore.configs import ConfigurationInstance, register
from configstore.forms import ConfigurationForm

class ExampleConfigurationForm(ConfigurationForm):
    amount = forms.DecimalField()
    message = forms.CharField()
    user = forms.ModelChoiceField(queryset=User.objects.all())

Register the form:

complex_instance = ConfigurationInstance('example', 'Example Config', ExampleConfigurationForm)
register(complex_instance)

Somewhere else in your code retrieve the config and use it:

from configstore.configs import get_config
config = get_config('example')
print config['amount']

About

An application to allow for other apps to easily store site based configurations. This fork is to allow the key to be dynamically generated so that we can have multiple instances of each config and do interesting things with them, such as attaching them to a feinCMS page etc..

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published