Clone the versioning_scheme when necessary. Fixes #2477

This commit is contained in:
Brandon Cazander 2015-01-27 17:10:17 -08:00
parent 107198af94
commit ac87490b91
2 changed files with 18 additions and 1 deletions

View File

@ -109,6 +109,8 @@ def clone_request(request, method):
ret.accepted_media_type = request.accepted_media_type
if hasattr(request, 'version'):
ret.version = request.version
if hasattr(request, 'versioning_scheme'):
ret.versioning_scheme = request.versioning_scheme
return ret

View File

@ -1,5 +1,5 @@
from __future__ import unicode_literals
from rest_framework import exceptions, serializers, status, views
from rest_framework import exceptions, serializers, status, views, versioning
from rest_framework.request import Request
from rest_framework.renderers import BrowsableAPIRenderer
from rest_framework.test import APIRequestFactory
@ -183,3 +183,18 @@ class TestMetadata:
view = ExampleView.as_view()
view(request=request)
def test_bug_2477_clone_request(self):
class ExampleView(views.APIView):
renderer_classes = (BrowsableAPIRenderer,)
def post(self, request):
pass
def get_serializer(self):
assert hasattr(self.request, 'versioning_scheme')
return serializers.Serializer()
scheme = versioning.QueryParameterVersioning
view = ExampleView.as_view(versioning_class=scheme)
view(request=request)