[Python] How to Display Total Object Count in Wagtail Snippet ViewSet?

Discussão em 'Python' iniciado por Stack, Setembro 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently developing a Wagtail project where I use the ModelAdmin to create custom admin interfaces for my models. When using ModelAdmin, the total object count of a model is displayed below the model name in the list view. However, when I switched to using SnippetViewSet, I lost this functionality.I would like to display the total object count in the list view based on the custom get_queryset method defined in my SnippetViewSet class.

    ModelAdmin: [​IMG]

    SnippetViewSet: [​IMG]


    class ModelBViewSet(SnippetViewSet):
    model = ModelB
    icon = 'folder'
    list_display = ["foo", "bar"]
    menu_name = "Unloaded Objects ModelB"

    def get_queryset(self, request):
    qs = ModelB.objects.filter(foo='foo')
    return qs



    register_snippet(ModelBViewSet)

    Continue reading...

Compartilhe esta Página