wagtailmodeladmin

Wagtail ModelAdmin. Several sections for custom User


I'm trying to set up Wagtail for existing custom User model. As per requirements several User pages should be available, representing different types of users (Regular, Manager, etc) I tried to make separate ModelAdmin for each case, overriding get_queryset for filtering by user type. But it looks like all of them show the first definition of ModelAdmin, as all of them has model - User

Then I tried to use Proxy model, in this case there is no display at all, as Wagtail seemingly doesn't support proxy models.

The only option I see now is to make my own views and add menu items leading to it

Please advice what is the best/easiest way to achieve this in Wagtail


Solution

  • Wagtail Admin actually works with Proxy Models. The missing part was that Wagtail permissions section doesn't include Proxy models, so you have to add it manually:

    from wagtail.contrib.modeladmin.helpers import PermissionHelper
    
    class ProxyModelPermissionHelper(PermissionHelper):
        def user_can_list(self, user):
            return True
    

    and in ModelAdmin:

    permission_helper_class = ProxyModelPermissionHelper