Wagtail ModelAdmin read only

陌路散爱 提交于 2019-12-06 01:44:45

Sadly, you need at least one of the add, change or delete permission on that model (set within the roles) for it to show up.

The way around that is to provide a custom permission helper class to your ModelAdmin and always allow listing (and still allow add/change/delete to be set within the roles):

class MyPermissionHelper(wagtail.contrib.modeladmin.helpers.PermissionHelper):
    def user_can_list(self, user):
        return True  # Or any logic related to the user.

class MyModelAdmin(wagtail.contrib.modeladmin.options.ModelAdmin):
    model = MyModel
    permission_helper_class = MyPermissionHelper

modeladmin_register(wagtail.contrib.modeladmin.options.MyModelAdmin)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!