CNK's Blog

Wagtail 3 upgrade: Per Site Settings Tab

Another feature we turn on and off per site is a tab worth of fields used for compiling reports for certain departments every 5 years or so. So most of the time, this information is not useful and we only want to collect it in the few months before that report is compiled. The rest of the time we don’t want that tab visible. For single fields, we can use the Permissioned FieldPanel as I described in a previous post.


Another place where we want to show or hide an entire tab is in our settings model: SitePreferences. We need to be able to allow some sites to hide parts of our header and footer - but we only want superusers to be able to make those changes. We have placed all those ‘superuser-only’ fields on a tab of their own and have been monkey patching the edit handler to use a different tabbed interface for users and superusers. In Wagtail 3 can use Permissioned FieldPanel to remove all the fields from the tab - but that still leaves the tab heading in place.


Refactor the settings edit view into a CBV and then override the bits we want.

Before that, we could just copy the edit view into our 2 cases