mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Merge pull request #2478 from brandoncazander/version-3.1
Clone the versioning_scheme when necessary. Fixes #2477
This commit is contained in:
commit
8f33e39f62
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user