Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-preferences

How to install django-preferences

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-preferences
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.0.6 Available View build log
0.0.5 Available View build log
0.0.4 Available View build log
0.0.3 Available View build log
0.0.2 Available View build log
Windows (64-bit)
0.0.6 Available View build log
0.0.5 Available View build log
0.0.4 Available View build log
0.0.3 Available View build log
0.0.2 Available View build log
Mac OS X (10.5+)
0.0.6 Available View build log
0.0.5 Available View build log
0.0.4 Available View build log
0.0.3 Available View build log
0.0.2 Available View build log
Linux (32-bit)
0.0.6 Available View build log
0.0.5 Available View build log
0.0.4 Available View build log
0.0.3 Available View build log
0.0.2 Available View build log
Linux (64-bit)
0.0.6 Available View build log
0.0.5 Available View build log
0.0.4 Available View build log
0.0.3 Available View build log
0.0.2 Available View build log
 
License
BSD
Dependencies
Lastest release
version 0.0.6 on May 23rd, 2012

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 per site is available for each Preferences class.

Note

django-preferences requires and supports Django's "sites" framework, which means you can have multiple preferences, each associated with a particular site.

Note

django-preferences version 0.0.5 and higher requires Django 1.3 and higher for correct operation. If you are getting the super vague Error: cannot import name receiver error on startup either update to Django 1.3 or use django-preferences version 0.0.4 or earlier.

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

  2. Add preferences to your INSTALLED APPS setting.

  3. Add django.contrib.sites to your INSTALLED APPS setting. django-preferences associates preferences to specific sites and thus requires Django's "sites" framework to be installed.

  4. Optionally, add preferences.context_processors.preferences_cp to your TEMPLATE_CONTEXT_PROCESSORS settings. This will automatically add a preferences variable to your template context if you use RequestContext to create your context (see Usage below), i.e.:

    TEMPLATE_CONTEXT_PROCESSORS = (
        ...other context processors...,
        "preferences.context_processors.preferences_cp",
    )
    
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 model's 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, except that they have to inherit from or be registered with preferences.admin.PreferencesAdmin, i.e.:

from django.contrib import admin

from preferences.admin import PreferencesAdmin
from <my_app>.models import MyPreferences

admin.site.register(MyPreferences, PreferencesAdmin)

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

If you've specified the preferences.context_processors.preferences_cp as a TEMPLATE_CONTEXT_PROCESSORS you can similarly access your preferences within templates through the preferences variable, i.e.:

{{ preferences.MyPreferences.portal_contact_email }}

Authors

Praekelt Foundation
  • Shaun Sephton
  • Euan Jonker
  • Hedley Roos

Changelog

0.0.6
  1. Better packaging.
0.0.5 (2011-08-17)
  1. Added sites support.
  2. Added unittests.
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.

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:4

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.