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.
Installation
Install or add django-new-preferences to your Python path.
Add preferences to your INSTALLED APPS setting.
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.
Optionally, add preferences.context_processors.preferences_cp to your template context processors settings. This will automatically add a preferences variable to your template context:
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):
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 }}
Changelog
next
Django 2 and Python 3.5 compatibility. Django 1.9 is no longer supported.
0.2
Move to tox for tests.
Django 1.9 to 1.11 support. The official minimum supported version is 1.9.
0.1
Cleanup and fixing of tests courtesy of senyor.
Rewrite distinct query so it works with Oracle backend.
0.0.6
Better packaging.
0.0.5 (2011-08-17)
Added sites support.
Added unittests.
0.0.4 (2011-08-11)
Cleanup. Docs polish.
0.0.3
Spelling correction, thanks tiktuk.
0.0.2
Doc update to indicate importance of placing url include before admin url include.
0.0.1
First super alpha release.
Release files for django-new-preferences 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-new-preferences-0.2.tar.gz | 10.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_new_preferences-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.2 kB
Release files / django-new-preferences-0.2.tar.gz
| Download URL | django-new-preferences-0.2.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
146145700a2226fdeaf9efa6677ebf43a95bf30d569b452e6c1514ba36764bce
|
|
BLAKE2b-256 checksum How to use checksums |
6a5c4d4ddd080ee49464cf840a80491e35b8da3209f20967a2ae9f778e8ec78e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|
Release files / django_new_preferences-0.2-py3-none-any.whl
| Download URL | django_new_preferences-0.2-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2a04ac9370e0c7c23f08889a6b61d578ff5dc075c404e7c7905b2a6105da5ac
|
|
BLAKE2b-256 checksum How to use checksums |
1cf4bf4740cdd5a91d4a47010de5bd992ea59336be925485c458fdcebc43a3d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|