aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/permissions.md
diff options
context:
space:
mode:
authorTom Christie2013-03-08 23:42:20 +0000
committerTom Christie2013-03-08 23:42:20 +0000
commit69d169f5f629c1d02361198c4a76839a9f8d528d (patch)
tree3e8c3701b15d1572f45334f586c80b61ed11288a /docs/api-guide/permissions.md
parent6c1fcc855a2d05732113ce260b8660a414e1961e (diff)
downloaddjango-rest-framework-69d169f5f629c1d02361198c4a76839a9f8d528d.tar.bz2
Neater override hooks and more docs for DjangoModelPermissions.
Refs #702.
Diffstat (limited to 'docs/api-guide/permissions.md')
-rw-r--r--docs/api-guide/permissions.md7
1 files changed, 6 insertions, 1 deletions
diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md
index 2db6ce1e..719ac1ef 100644
--- a/docs/api-guide/permissions.md
+++ b/docs/api-guide/permissions.md
@@ -90,12 +90,17 @@ This permission is suitable if you want to your API to allow read permissions to
## DjangoModelPermissions
-This permission class ties into Django's standard `django.contrib.auth` [model permissions][contribauth]. When applied to a view that has a `.model` property, authorization will only be granted if the user has the relevant model permissions assigned.
+This permission class ties into Django's standard `django.contrib.auth` [model permissions][contribauth]. When applied to a view that has a `.model` property, authorization will only be granted if the user *is authenticated* and has the *relevant model permissions* assigned.
* `POST` requests require the user to have the `add` permission on the model.
* `PUT` and `PATCH` requests require the user to have the `change` permission on the model.
* `DELETE` requests require the user to have the `delete` permission on the model.
+If you want to use `DjangoModelPermissions` but also allow unauthenticated users to have read permission, override the class and set the `authenticated_users_only` property to `False`. For example:
+
+ class HasModelPermissionsOrReadOnly(DjangoModelPermissions):
+ authenticated_users_only = False
+
The default behaviour can also be overridden to support custom model permissions. For example, you might want to include a `view` model permission for `GET` requests.
To use custom model permissions, override `DjangoModelPermissions` and set the `.perms_map` property. Refer to the source code for details.