Wagtail is wonderfull CMS. I do have a question how to add submenu's in the admin. I got a custom model Locations in that model I got 2 foreignkeys. To manage the locations model in created via modeladmin a menu. However to manage the city's or foreignkey content I also need to create in modeladmin.
I only see an option in modeladmin to add the item to the settings menu. What I need in my admin is the following
+ pages
++ ...
+ locations
++ locations
++ cities
++ tags
+ ...
Currently I only can determine the order via the menu_order=200
Is there a way to make the navigation in wagtail have sub nav
You can use ModelAdminGroup
to group several ModelAdmin views into a submenu:
http://docs.wagtail.io/en/stable/reference/contrib/modeladmin/index.html#a-more-complicated-example
from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup, modeladmin_register
class LocationGroup(ModelAdminGroup):
menu_label = 'Locations'
items = (LocationAdmin, CityAdmin, TagAdmin)
modeladmin_register(LocationGroup)
Ah I found it.
You can use ModelAdminGroup
https://docs.wagtail.io/en/v2.7/reference/contrib/modeladmin/index.html#summary-of-features
menu_label = 'Library'
menu_icon = 'folder-open-inverse' # change as required
menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd)
items = (BookAdmin, AuthorAdmin, GenreAdmin)
# When using a ModelAdminGroup class to group several ModelAdmin classes together,
# you only need to register the ModelAdminGroup class with Wagtail:
modeladmin_register(LibraryGroup)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With