mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
Assert context not in kwargs
Raise and AssertionError whenever a `context` argument is passed to the `get_serializer`
This commit is contained in:
parent
4602333f6e
commit
ad99b8e253
|
@ -106,14 +106,13 @@ class GenericAPIView(views.APIView):
|
|||
deserializing input, and for serializing output.
|
||||
"""
|
||||
serializer_class = self.get_serializer_class()
|
||||
|
||||
# Include view's custom context
|
||||
default_context = self.get_serializer_context()
|
||||
if 'context' in kwargs:
|
||||
kwargs['context'].update(default_context)
|
||||
else:
|
||||
kwargs['context'] = default_context
|
||||
|
||||
|
||||
assert 'context' not in kwargs, (
|
||||
"`get_serializer` does not accept a `context` argument, "
|
||||
"you may override `get_serializer_context` instead."
|
||||
)
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
|
||||
return serializer_class(*args, **kwargs)
|
||||
|
||||
def get_serializer_class(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user