1
我有以下用戶資源代碼,如何插入'permissions field'
,它返回用戶的權限列表?如何在用戶資源中插入user_permissions字段?
class UserResource(ModelResource):
user_permissions = fields.ToManyField #??????
class Meta:
queryset = User.objects.all()
resource_name = 'user'
authorization = Authorization()
always_return_data = True
list_allowed_methods = ['get', 'post', 'put', 'delete']
authorization = DjangoAuthorization()
authentication = MultiAuthentication(BasicAuthentication(), SessionAuthentication())
filtering = {
"date_joined": ALL,
"email": ALL,
"first_name": ALL,
"is_active": ALL,
"is_staff": ALL,
"is_superuser": ALL,
"last_login": ALL,
"last_name": ALL,
"username": ALL,
"user_permissions": ALL_WITH_RELATIONS,
}