mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
Update generics.py
Fix GenericAPIView.get_serializer(self, *args, **kwargs) ignores context in kwargs and replaces it (which may be used by views) with its default context
This commit is contained in:
parent
d22daf4e05
commit
fa78886581
|
@ -106,7 +106,14 @@ class GenericAPIView(views.APIView):
|
||||||
deserializing input, and for serializing output.
|
deserializing input, and for serializing output.
|
||||||
"""
|
"""
|
||||||
serializer_class = self.get_serializer_class()
|
serializer_class = self.get_serializer_class()
|
||||||
kwargs['context'] = self.get_serializer_context()
|
|
||||||
|
# Include view's costum context
|
||||||
|
default_context = self.get_serializer_context()
|
||||||
|
if 'context' in kwargs:
|
||||||
|
kwargs['context'].update(default_context)
|
||||||
|
else:
|
||||||
|
kwargs['context'] = default_context
|
||||||
|
|
||||||
return serializer_class(*args, **kwargs)
|
return serializer_class(*args, **kwargs)
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user