You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-guide/permissions.md
+10
Original file line number
Diff line number
Diff line change
@@ -190,6 +190,16 @@ If you need to test if a request is a read operation or a write operation, you s
190
190
191
191
---
192
192
193
+
Custom permissions will raise a `PermissionDenied` exception if the test fails. To change the error message associated with the exception, implement a `message` attribute directly on your custom permission. Otherwise the `default_detail` attribute from `PermissionDenied` will be used.
194
+
195
+
from rest_framework import permissions
196
+
197
+
class CustomerAccessPermission(permissions.BasePermission):
198
+
message = 'Adding customers not allowed.'
199
+
200
+
def has_permission(self, request, view):
201
+
...
202
+
193
203
## Examples
194
204
195
205
The following is an example of a permission class that checks the incoming request's IP address against a blacklist, and denies the request if the IP has been blacklisted.
0 commit comments