Skip to main content

Django app allowing users to set app specific preferences through the admin interface.

Project description

Django Preferences

Django app allowing users to set app specific preferences through the admin interface.

Provides singleton admin views for Preferences objects and a simple interface to preference values. Singleton views ensure only one preference intance is available for each Preferences class.

Installation

  1. Install or add django-preferences to your Python path.

  2. Add preferences to your INSTALLED APPS setting.

  3. Add preferences url include to the project’s url.py file BEFORE your admin urls include statement. Make sure to use 'admin/' as the start of the include’s path since it will override certain admin views:

    (r'^admin/', include('preferences.urls')),
    

Usage

To create preferences for your app create a Django ORM model as usual, with the model inheriting from preferences.models.Preferences. Also specify preferences.models as your models module:

from django.db import models
from preferences.models import Preferences

class MyPreferences(Preferences):
    __module__ = 'preferences.models'
    portal_contact_email = models.EmailField()

Admin classes are specified as per usual, no changes are needed. When your model is registered with admin it will show up under the Preferences app label in Django admin.

Preferences can be accessed in Python by importing the preferences module and traversing to your required preference in the form preferences.<ModelName>.<field>, i.e.:

from preferences import preferences

portal_contact_email = preferences.MyPreferences.portal_contact_email

Authors

Praekelt Foundation

  • Shaun Sephton
  • Euan Jonker

Changelog

0.0.4 (2011-08-11)

  1. Cleanup. Docs polish.

0.0.3

  1. Spelling correction, thanks tiktuk.

0.0.2

  1. Doc update to indicate importance of placing url include before admin url include.

0.0.1

  1. First super alpha release.

Project details


Download files

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

Files for django-preferences, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size django_preferences-0.0.4-py2.6.egg (6.9 kB) File type Egg Python version 2.6 Upload date Hashes View
Filename, size django_preferences-0.0.4-py2.7.egg (6.9 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size django-preferences-0.0.4.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page