1. def get_list_editable(self, request):
    2. group_names = self.get_group_names(request.user)
    3. if request.user.is_superuser or 'hr' in group_names:
    4. return self.default_list_editable
    5. return ()

    django 不会主动调用 get_list_editable,需要在 get_changelist_instance 中覆盖

    1. def get_changelist_instance(self, request):
    2. # 覆盖父类 获取 list_editable 的方法
    3. self.list_editable = self.get_list_editable(request)
    4. return super(CandidateAdmin, self).get_changelist_instance(request)