djangodjango-modelsdjango-adminwagtailwagtail-snippet

Use Wagtail CMS Snippets but Hide in Admin Panel


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.

enter image description here


Solution

  • 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/