【发布时间】:2021-11-13 14:17:16
【问题描述】:
我在 Django 中有这个权限,看起来像这样:
class PermissionName(BasePermission):
def has_object_permission(self, request, view, obj):
if request.method in SAFE_METHODS:
return True
#I want to extract the pk or id params in here.
return False
谁能帮我获取我尝试使用self.kwargs["pk"]、request.POST['pk'] 的请求参数,但他们都返回说对象没有属性。
【问题讨论】:
-
既然给你对象,
obj.pk? -
pk 或 id 是什么?
-
@WillemVanOnsem 有效,谢谢!
标签: python django django-rest-framework django-permissions