Search code examples
djangopermissionswagtaildjango-permissionswagtail-admin

Wagtail Admin - Allow Editor to Edit Custom Setting


I have created a custom setting in Wagtail, allowing an alert banner to be edited in the admin.

from django.db import models
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.admin.edit_handlers import FieldPanel

from ckeditor.fields import RichTextField


@register_setting
class AlertBanner(BaseSetting):
    enable_alert_banner = models.BooleanField(default=False)
    text = RichTextField(max_length=3000, default="", blank=True)

    panels = [
        FieldPanel('enable_alert_banner'),
        FieldPanel('text'),
    ]

    class Meta:
        verbose_name = "Alert Banner"

I don't want to have to give Admin privileges to certain users in order for them to access this. Is there a way that I can allow Editors to access this setting from the admin menu?


Solution

  • Under Settings -> Groups in the Wagtail admin backend, select the Editors group (or whichever user group you want to give access to the setting). You'll find the settings model you defined in the "Object permissions" list:

    Alert Banner shown in the Object Permissions list

    Tick the box to give the group 'change' permission, and save - users in the Editors group will now see it as an option in their admin menu.