I am building custom AdminModels based on Wagtail Snippets and have a custom menu in the AdminPanel for my models. How do I hide/remove the Snippet selection from AdminPanel without disabling? Thank you.
Use Wagtail CMS Snippets but Hide in Admin Panel
Asked Answered
Can u please put some code .. and my suggestion is to remove admin.site.register() which u want to remove –
Pestle
Put the following hook into wagtail_hooks.py file of your Wagtail CMS app:
from wagtail.wagtailcore import hooks
@hooks.register('construct_main_menu')
def hide_snippets_menu_item(request, menu_items):
menu_items[:] = [item for item in menu_items if item.name != 'snippets']
And you're basically done! You can use this approach to hide any item from the admin menu.
I described it recently on my blog: http://timonweb.com/posts/how-to-remove-snippets-menu-item-from-wagtail-cms-admin-menu/
Awesome! Thank You. –
Subtorrid
Since item.name
in menu_items
can be blank, better solution is:
from wagtail.snippets.wagtail_hooks import SnippetsMenuItem
@hooks.register('construct_main_menu')
def hide_snippets_menu_item(request, menu_items):
menu_items[:] = [item for item in menu_items if not isinstance(item, SnippetsMenuItem)]
I had an issue using the accepted answer because we use multiple names, depending on the user's language.. This solution is actually better –
Gaunt
Put the following hook into wagtail_hooks.py file of your Wagtail CMS app:
from wagtail.wagtailcore import hooks
@hooks.register('construct_main_menu')
def hide_snippets_menu_item(request, menu_items):
menu_items[:] = [item for item in menu_items if item.name != 'snippets']
And you're basically done! You can use this approach to hide any item from the admin menu.
I described it recently on my blog: http://timonweb.com/posts/how-to-remove-snippets-menu-item-from-wagtail-cms-admin-menu/
Awesome! Thank You. –
Subtorrid
© 2022 - 2025 — McMap. All rights reserved.