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


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


django-new-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-new-preferences version 0.0.4 or earlier.


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

  2. Add preferences to your INSTALLED APPS setting.

  3. Add django.contrib.sites to your INSTALLED APPS setting. django-new-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:

        ...other context processors...,


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):
    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, 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 }}


Praekelt Consulting

  • Shaun Sephton
  • Euan Jonker
  • Hedley Roos



  1. Move to tox for tests.
  2. Django 1.9 to 1.11 support. The official minimum supported version is 1.9.


  1. Cleanup and fixing of tests courtesy of senyor.
  2. Rewrite distinct query so it works with Oracle backend.


  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.


  1. Spelling correction, thanks tiktuk.


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


  1. First super alpha release.

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for django-new-preferences, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size django_new_preferences-0.2-py3-none-any.whl (13.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-new-preferences-0.2.tar.gz (10.2 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