Reusable app for Django introducing site preferences system
Project description
http://github.com/idlesign/django-siteprefs
What’s that
django-siteprefs allows Django applications settings to come alive
Let’s suppose you have your pretty settings.py file with you application:
from django.conf import settings MY_OPTION_1 = getattr(settings, 'MY_APP_MY_OPTION_1', True) MY_OPTION_2 = getattr(settings, 'MY_APP_MY_OPTION_2', 'No alien utopia // Will long survive our bravery') MY_OPTION_42 = getattr(settings, 'MY_APP_MY_OPTION_42', 42)
Now you want these options to be exposed to Django Admin interface:
from django.conf import settings MY_OPTION_1 = getattr(settings, 'MY_APP_MY_OPTION_1', True) MY_OPTION_2 = getattr(settings, 'MY_APP_MY_OPTION_2', 'No alien utopia // Will long survive our bravery') MY_OPTION_42 = getattr(settings, 'MY_APP_MY_OPTION_42', 42) # To be sure our app is still functional without django-siteprefs # we use this try-except block. try: from siteprefs.toolbox import patch_locals, register_prefs patch_locals() # This bootstrap is required before `register_prefs` step. # And that's how we expose our options to Admin. register_prefs(MY_OPTION_1, MY_OPTION_2, MY_OPTION_42) except ImportError: pass
We’re done with the app. Now to your settings.py of your project.
Add siteprefs into INSTALLED_APPS;
Use siteprefs autodiscover_siteprefs function to locate all the options exposed by apps in your project:
from siteprefs.toolbox import autodiscover_siteprefs autodiscover_siteprefs()
Now you can view your settings in Django Admin.
If you want those settings to be editable through the Admin - siteprefs allows that too, and even more.
Read the docs ;)
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-siteprefs-0.5.3.tar.gz
.
File metadata
- Download URL: django-siteprefs-0.5.3.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9b7612511da57db4c56815d122aacacd6400a0bbcf45d7fc25ef90ca0f24941 |
|
MD5 | 07e993b5fc5f446f400632960e6d2573 |
|
BLAKE2b-256 | f58c047870b4d6bd1d9555e078cceddf7babc9b3bf43c87618beaa5de34558e0 |
Provenance
File details
Details for the file django_siteprefs-0.5.3-py2.py3-none-any.whl
.
File metadata
- Download URL: django_siteprefs-0.5.3-py2.py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a8f20e2518f88c21ccad5c95733a5f971e3417c27cb2f1419a695e14e815e8b |
|
MD5 | a6d37aa1bf9485c0f1ac9824cbc25006 |
|
BLAKE2b-256 | d304704e5c5af91c6ee1a1feb7d6a6c9f38c0ecd9472424121dece3a0b5701ef |