From ad1e05b36aa86677e9d41104e977bce6dec9689c Mon Sep 17 00:00:00 2001 From: Sanjuro Jogdeo Date: Thu, 7 Sep 2017 16:02:47 -0700 Subject: [PATCH 1/2] 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... --- docs/api-guide/permissions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md index 548b14438b..a7ea288f95 100644 --- a/docs/api-guide/permissions.md +++ b/docs/api-guide/permissions.md @@ -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 From 83c07fb1d56677103cdd4fa58566b2299fb418b8 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Fri, 8 Sep 2017 18:11:39 +0200 Subject: [PATCH 2/2] Adjust patch --- docs/api-guide/permissions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md index a7ea288f95..ef9ce3abd3 100644 --- a/docs/api-guide/permissions.md +++ b/docs/api-guide/permissions.md @@ -43,8 +43,8 @@ This will either raise a `PermissionDenied` or `NotAuthenticated` exception, or For example: - def get_object(self, pk): - obj = get_object_or_404(self.get_queryset(), pk=pk) + def get_object(self): + obj = get_object_or_404(self.get_queryset(), pk=self.kwargs["pk"]) self.check_object_permissions(self.request, obj) return obj pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy