Skip to content

Commit 6d4d048

Browse files
committed
Updated documentation and simplified code
1 parent ecae64f commit 6d4d048

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

docs/api-guide/permissions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,12 @@ This permission is suitable if you want to your API to allow read permissions to
173173

174174
This permission class ties into Django's standard `django.contrib.auth` [model permissions][contribauth]. This permission must only be applied to views that have a `.queryset` property or `get_queryset()` method. Authorization will only be granted if the user *is authenticated* and has the *relevant model permissions* assigned. The appropriate model is determined by checking `get_queryset().model` or `queryset.model`.
175175

176+
* `GET` requests require the user to have the `view` or `change` permission on the model
176177
* `POST` requests require the user to have the `add` permission on the model.
177178
* `PUT` and `PATCH` requests require the user to have the `change` permission on the model.
178179
* `DELETE` requests require the user to have the `delete` permission on the model.
179180

180-
The default behavior can also be overridden to support custom model permissions. For example, you might want to include a `view` model permission for `GET` requests.
181+
The default behaviour can also be overridden to support custom model permissions.
181182

182183
To use custom model permissions, override `DjangoModelPermissions` and set the `.perms_map` property. Refer to the source code for details.
183184

rest_framework/permissions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,7 @@ def has_permission(self, request, view):
243243

244244
user = request.user
245245
if request.method == 'GET':
246-
if user.has_perms(perms) or user.has_perms(change_perm):
247-
return True
248-
else:
249-
return False
246+
return user.has_perms(perms) or user.has_perms(change_perm)
250247

251248
return user.has_perms(perms)
252249

0 commit comments

Comments
 (0)