From 1f72fd42bcefcf5a2763f9516c06c0a91364a260 Mon Sep 17 00:00:00 2001 From: NK Date: Mon, 7 Apr 2014 17:17:34 +0300 Subject: [PATCH] The OPTIONS method creates a cloned-request to simulate PUT/POST methods. But the implementation did not propagate the cloned-request to the View. This caused views that change the serializer per the http-method to return the incorrect serializer. --- rest_framework/generics.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 7bac510f7..346d74032 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -371,10 +371,11 @@ class GenericAPIView(views.APIView): if method not in self.allowed_methods: continue - cloned_request = clone_request(request, method) + original_request = clone_request(request, request.method) + self.request = clone_request(request, method) try: # Test global permissions - self.check_permissions(cloned_request) + self.check_permissions(self.request) # Test object permissions if method == 'PUT': try: @@ -392,6 +393,7 @@ class GenericAPIView(views.APIView): # appropriate metadata about the fields that should be supplied. serializer = self.get_serializer() actions[method] = serializer.metadata() + self.request = original_request if actions: ret['actions'] = actions