Wagtail ModelAdmin.自定义用户的几个部分 [英] Wagtail ModelAdmin. Several sections for custom User

查看:104
本文介绍了Wagtail ModelAdmin.自定义用户的几个部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为现有的自定义用户模型设置Wagtail.根据要求,应该有几个用户页面,分别代表不同类型的用户(常规用户,管理者等) 我尝试为每种情况制作单独的ModelAdmin,重写get_queryset以便按用户类型进行过滤.但似乎所有人都显示了ModelAdmin的第一个定义,因为所有人都有模型-用户

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

然后我尝试使用代理模型,在这种情况下根本没有显示,因为Wagtail似乎不支持代理模型.

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

请告知在Wa中实现此目的的最佳/最简单方法是什么

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

推荐答案

Wagtail Admin实际上与代理模型一起使用.缺少的部分是Wagtail权限部分不包括代理模型,因此您必须手动添加它:

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

ModelAdmin中的

permission_helper_class = ProxyModelPermissionHelper

这篇关于Wagtail ModelAdmin.自定义用户的几个部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆