easily manage typed extra settings using the django admin.
Project description
django-extra-settings
config and manage typed extra settings using just the django admin.
Installation
- Run
pip install django-extra-settings
- Add
extra_settings
tosettings.INSTALLED_APPS
- Run
python manage.py migrate
- Run
python manage.py collectstatic
- Restart your application server
Usage
Admin
Just go to the admin where you can:
- Create a new setting
- Update an existing setting
- Delete an existing setting
Settings
All these settings are optional, if not defined in settings.py
the default values (listed below) will be used.
# if True the template tag will fallback to django.conf.settings,
# very useful to retrieve conf settings such as DEBUG.
EXTRA_SETTINGS_FALLBACK_TO_CONF_SETTINGS = True
# the upload_to path value of settings of type 'file'
EXTRA_SETTINGS_FILE_UPLOAD_TO = 'files'
# the upload_to path value of settings of type 'image'
EXTRA_SETTINGS_IMAGE_UPLOAD_TO = 'images'
Admin
Just go to the admin where you can:
- Create a new setting
- Update an existing setting
- Delete an existing setting
Python
You can create, read, update and delete settings programmatically:
Create
from extra_settings.models import Setting
setting_obj = Setting(
name='SETTING_NAME',
value_type=Setting.TYPE_STRING,
value='django-extra-settings',
)
setting_obj.save()
Read
from extra_settings.models import Setting
value = Setting.get('SETTING_NAME', default='django-extra-settings')
Update
from extra_settings.models import Setting
setting_obj = Setting(
name='SETTING_NAME',
value_type=Setting.TYPE_BOOL,
value=True,
)
setting_obj.value = False
setting_obj.save()
Delete
from extra_settings.models import Setting
Setting.objects.filter(name='SETTING_NAME').delete()
This is the list of the currently supported setting types you may need to use:
Setting.TYPE_BOOL
Setting.TYPE_DATE
Setting.TYPE_DATETIME
Setting.TYPE_DECIMAL
Setting.TYPE_DURATION
Setting.TYPE_EMAIL
Setting.TYPE_FILE
Setting.TYPE_FLOAT
Setting.TYPE_IMAGE
Setting.TYPE_INT
Setting.TYPE_STRING
Setting.TYPE_TEXT
Setting.TYPE_TIME
Setting.TYPE_URL
Templates
You can retrieve settings in templates:
{% load extra_settings %}
{% get_setting 'SETTING_NAME' default='django-extra-settings' %}
Testing
# create python virtual environment
virtualenv testing_django_extra_settings
# activate virtualenv
cd testing_django_extra_settings && . bin/activate
# clone repo
git clone https://github.com/fabiocaccamo/django-extra-settings.git src && cd src
# install dependencies
pip install -r requirements.txt
pip install -r requirements-test.txt
# run tests
tox
# or
python setup.py test
# or
python -m django test --settings "tests.settings"
License
Released under MIT License.
See also
-
django-admin-interface
- the default admin interface made customizable by the admin itself. popup windows replaced by modals. 🧙 ⚡ -
django-colorfield
- simple color field for models with a nice color-picker in the admin. 🎨 -
django-maintenance-mode
- shows a 503 error page when maintenance-mode is on. 🚧 🛠️ -
django-redirects
- redirects with full control. ↪️ -
django-treenode
- probably the best abstract model / admin for your tree based stuff. 🌳 -
python-benedict
- dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘 -
python-codicefiscale
- encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. 🇮🇹 💳 -
python-fontbro
- friendly font operations. 🧢 -
python-fsutil
- file-system utilities for lazy devs. 🧟♂️
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
Hashes for django-extra-settings-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11b0a1eac1a9d5e68b033b72d5de65570c9e43dd3c05af331f27e4b2c8c59192 |
|
MD5 | 624f9b951419042e5d5f089175b1d2c6 |
|
BLAKE2b-256 | fff5f4d8737ef7054e98ae36fa1524b2ff66dd59b1fad18775a626e599ed6cb8 |
Hashes for django_extra_settings-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a02e8886868cce8155ac18dfd0cf3d3c1c6c4600e6dcaf101afaa983dbde34ab |
|
MD5 | 63ae5333732a450b74f2275300991a85 |
|
BLAKE2b-256 | 4859f203bb205c8ea4b2eeb4fa23828d8e931b6392f8f149fd71a8715a3f8fcb |