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.

This commit is contained in:
NK 2014-04-07 17:17:34 +03:00
parent 115fe04842
commit 1f72fd42bc

View File

@ -371,10 +371,11 @@ class GenericAPIView(views.APIView):
if method not in self.allowed_methods: if method not in self.allowed_methods:
continue continue
cloned_request = clone_request(request, method) original_request = clone_request(request, request.method)
self.request = clone_request(request, method)
try: try:
# Test global permissions # Test global permissions
self.check_permissions(cloned_request) self.check_permissions(self.request)
# Test object permissions # Test object permissions
if method == 'PUT': if method == 'PUT':
try: try:
@ -392,6 +393,7 @@ class GenericAPIView(views.APIView):
# appropriate metadata about the fields that should be supplied. # appropriate metadata about the fields that should be supplied.
serializer = self.get_serializer() serializer = self.get_serializer()
actions[method] = serializer.metadata() actions[method] = serializer.metadata()
self.request = original_request
if actions: if actions:
ret['actions'] = actions ret['actions'] = actions