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
File details
Details for the file wagtail-global-settings-0.1.1.tar.gz
.
File metadata
- Download URL: wagtail-global-settings-0.1.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d372d4d5341af20e144ffc8f1403402bfa45c2eb41a63a2e33ad041d992e33f |
|
MD5 | e70946d0c4415f335cf3b36e085c0498 |
|
BLAKE2b-256 | 575b21a3001e3336590c6f75c652b9d0eb0d5b0b2a6972f1dff0ff3114f13574 |