mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 10:03:57 +03:00
Merge pull request #2705 from diwu1989/patch-1
use SAFE_METHODS and make tuple
This commit is contained in:
commit
74506ba8ed
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from rest_framework.compat import get_model_name
|
from rest_framework.compat import get_model_name
|
||||||
|
|
||||||
SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS']
|
SAFE_METHODS = ('GET', 'HEAD', 'OPTIONS')
|
||||||
|
|
||||||
|
|
||||||
class BasePermission(object):
|
class BasePermission(object):
|
||||||
|
@ -185,7 +185,7 @@ class DjangoObjectPermissions(DjangoModelPermissions):
|
||||||
# they have read permissions to see 403, or not, and simply see
|
# they have read permissions to see 403, or not, and simply see
|
||||||
# a 404 response.
|
# a 404 response.
|
||||||
|
|
||||||
if request.method in ('GET', 'OPTIONS', 'HEAD'):
|
if request.method in SAFE_METHODS:
|
||||||
# Read permissions already checked and failed, no need
|
# Read permissions already checked and failed, no need
|
||||||
# to make another lookup.
|
# to make another lookup.
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
Loading…
Reference in New Issue
Block a user