Replace ModelAdmin usage with snippets
thibaudcolas opened this issue · 0 comments
thibaudcolas commented
#439 moves the site to the wagtail-modeladmin package. We can go one step further and move to Snippets.
The site’s ModelAdmin usage is all in the one base/wagtail_hooks.py
. Excerpt:
class BreadIngredientAdmin(ModelAdmin):
# These stub classes allow us to put various models into the custom "Wagtail Bakery" menu item
# rather than under the default Snippets section.
model = BreadIngredient
search_fields = ("name",)
inspect_view_enabled = True
class BreadTypeAdmin(ModelAdmin):
model = BreadType
search_fields = ("title",)
class BreadCountryAdmin(ModelAdmin):
model = Country
search_fields = ("title",)
class BreadModelAdminGroup(ModelAdminGroup):
menu_label = "Bread Categories"
menu_icon = "suitcase" # change as required
menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd)
items = (BreadIngredientAdmin, BreadTypeAdmin, BreadCountryAdmin)
modeladmin_register(BreadModelAdminGroup)
Our official migration documentation: https://docs.wagtail.org/en/stable/reference/contrib/modeladmin/migrating_to_snippets.html