Reputation: 171
I want to apply permission only for "PUT" method not for "POST"
class Signup(APIView):
def post(self, request, format=None):
something...something
@authentication_classes((ExpiringTokenAuthentication,))
@permission_classes((IsAuthenticated,))
def put(self, request, format=None):
something...something
Upvotes: 3
Views: 1235
Reputation: 4775
Check the HTTP method on your permission class has_permission
method and apply your checks if it was PUT:
class ExpiringTokenAuthentication(permissions.BasePermission):
def has_permission(self, request, view):
if request.method == 'PUT':
# do it here
class Signup(APIView):
permission_classes = (BlacklistPermission,)
Upvotes: 3