mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
added note to docs for custom permissions
This commit is contained in:
parent
b40525d8e6
commit
6268e99008
|
@ -174,6 +174,12 @@ To implement a custom permission, override `BasePermission` and implement either
|
|||
|
||||
The methods should return `True` if the request should be granted access, and `False` otherwise.
|
||||
|
||||
---
|
||||
|
||||
**Note**: If `has_permission()` doesn't return True and grants access `has_object_permission()` will never be called.
|
||||
|
||||
---
|
||||
|
||||
If you need to test if a request is a read operation or a write operation, you should check the request method against the constant `SAFE_METHODS`, which is a tuple containing `'GET'`, `'OPTIONS'` and `'HEAD'`. For example:
|
||||
|
||||
if request.method in permissions.SAFE_METHODS:
|
||||
|
|
Loading…
Reference in New Issue
Block a user