from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register, ModelAdminGroup) from wagtail.core import hooks from .models import Book, Author, Genre @hooks.register('construct_main_menu') def hide_images_menu_item(request, menu_items): menu_items[:] = [item for item in menu_items if item.name != 'help'] # @hooks.register('construct_settings_menu') # def hide_user_menu_item(request, menu_items): # menu_items[:] = [item for item in menu_items if item.name != 'user'] class BookAdmin(ModelAdmin): model = Book menu_label = 'Book' # ditch this to use verbose_name_plural from model menu_icon = 'pilcrow' # change as required # menu_order = 3000 # will put in 3rd place (000 being 1st, 100 2nd) # add_to_settings_menu = True # or True to add your model to the Settings sub-menu # exclude_from_explorer = True # or True to exclude pages of this type from Wagtail's explorer view list_display = ('title', 'author', 'cover_photo') list_filter = ('author',) search_fields = ('title', 'author') class AuthorAdmin(ModelAdmin): model = Author menu_label = 'Author' # ditch this to use verbose_name_plural from model menu_icon = 'user' # change as required list_display = ('first_name', 'last_name') list_filter = ('first_name', 'last_name') search_fields = ('first_name', 'last_name') class GenreAdmin(ModelAdmin): model = Genre menu_label = 'Genre' # ditch this to use verbose_name_plural from model menu_icon = 'group' # change as required list_display = ('name',) list_filter = ('name',) search_fields = ('name',) class LibraryGroup(ModelAdminGroup): menu_label = 'Library' menu_icon = 'folder-open-inverse' # change as required menu_order = 2000 # will put in 3rd place (000 being 1st, 100 2nd) items = (BookAdmin, AuthorAdmin, GenreAdmin) # Now you just need to register your customised ModelAdmin class with Wagtail # modeladmin_register(LibraryGroup) # modeladmin_register(BookAdmin) # modeladmin_register(AuthorAdmin) # modeladmin_register(GenreAdmin)