mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
Merge 6268e99008
into a857dab79c
This commit is contained in:
commit
faad0f74c2
|
@ -183,6 +183,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.
|
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 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:
|
if request.method in permissions.SAFE_METHODS:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user