Wagtail 5.1 - Hidding promote tab will stop any user from editing a page

85 views Asked by At

I currently have a wagtail 5.1 project where there's a need to hide the promote tab.

I'm hiding the tab like this:

from wagtail.admin.panels import (
    TabbedInterface, 
    ObjectList,
    ...
)

...

edit_handler = TabbedInterface([
    ObjectList(content_panels, heading='Content'),
    ObjectList(Page.promote_panels, heading='Promote', permission="superuser"),
])

The problem is that, any user besides the wagtail admin cannot save the edited page. A normal user with the group Moderator or Editor (or both) although he is not able to see the tab (what I want) he is not able to save the page because of the required slug in that tab.

enter image description here

Is there any workaround or am I stuck with this?

Thank you in advance.

1

There are 1 answers

0
Floaterz On

I think I managed to find an answer to this.

At the end of the CustomClassPage add this:

CustomClassPage._meta.get_field("slug").blank = True

Example:

...

class CustomClassPage(Page):
    
    ...

    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(Page.promote_panels, heading='Promote', permission="superuser"),
    ])

CustomClassPage._meta.get_field("slug").blank = True

After doing this and testing with a normal user he was able to edit and save the page. enter image description here