Global settings editor for Wagtail using django-solo
Project description
Global settings editor for Wagtail using django-solo
wagtail-global-settings provides a global singleton model editing interface and frontend access for Wagtail. It uses django-solo for the model.
Installation
Install wagtail-global-settings.
Add wagtail_global_settings to INSTALLED_APPS in your settings.py. It should be after any apps that use the global_settings_tags template tags.
Usage
To use wagtail-global-settings you need to define a model, which inherits from AbstractGlobalSettingsCollection:
class GlobalSettings(AbstractGlobalSettingsCollection):
facebook_app_id = models.CharField(max_length=256)
google_app_id = models.CharField(max_length=256)
analytics_id = models.CharField(max_length=256)
panels = [
FieldPanel('facebook_app_id'),
FieldPanel('google_app_id),
FieldPanel('analytics_id'),
]
class Meta:
verbose_name = "Global settings"
For the frontend you have three options:
use the context processor:
Add 'wagtail_global_settings.context_processors.global_settings' to your TEMPLATE_CONTEXT_PROCESSORS and then use the settings in your template: {{ global_settings.home.GlobalSettings.facebook_app_id }}
use the template tags:
Add {% load global_settings_tags %} at the beginning of your template and then use the tags in your template: {% global_settings 'home' 'GlobalSettings' 'facebook_app_id' %} or {% get_global_settings 'home' 'GlobalSettings' 'facebook_app_id' as facebook_app_id %} {{ facebook_app_id }}. It’s possible to skip the field name, in which case you’ll get the singleton model instance: {% get_global_settings 'home' 'GlobalSettings' as global_settings %} {{ global_settings.facebook_app_id }}
use the template tags provided by django-solo:
Add {% load solo_tags %} at the beginning of your template and then use the tag in your template: {% get_solo 'home.GlobalSettings' as global_settings %} {{ global_settings.facebook_app_id }}
For more information about configuration and caching see django-solo.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for wagtail-global-settings-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f613712b7156b9a5b9f3de51ccb3281ee68fa878ce544e3652f33292db513da1 |
|
MD5 | e82aa5f4e4566cd744b8c6e827ec2bb0 |
|
BLAKE2b-256 | 63cf4b5ed602fe2788fc05d5354794d4d27eeb5ea93ee7adbb92069f12404a92 |