mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Update get_object() example in permissions.md
I'm a bit confused about the example that's provided in the 'Object level permissions' section. Other examples (e.g. Tutorial 3 - Class Based Views) provided a pk to get_object(). It doesn't seem like this example has any way of identifying a specific object. Just in case I'm correct, I've prepared this pull request. But if I'm wrong, would it be possible for you to explain the example I modified? Many Thanks...
This commit is contained in:
parent
e2b5cef52c
commit
ad1e05b36a
|
@ -43,8 +43,8 @@ This will either raise a `PermissionDenied` or `NotAuthenticated` exception, or
|
|||
|
||||
For example:
|
||||
|
||||
def get_object(self):
|
||||
obj = get_object_or_404(self.get_queryset())
|
||||
def get_object(self, pk):
|
||||
obj = get_object_or_404(self.get_queryset(), pk=pk)
|
||||
self.check_object_permissions(self.request, obj)
|
||||
return obj
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user