mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +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
|
@ -107,12 +107,11 @@ class GenericAPIView(views.APIView):
|
||||||
"""
|
"""
|
||||||
serializer_class = self.get_serializer_class()
|
serializer_class = self.get_serializer_class()
|
||||||
|
|
||||||
# Include view's custom context
|
assert 'context' not in kwargs, (
|
||||||
default_context = self.get_serializer_context()
|
"`get_serializer` does not accept a `context` argument, "
|
||||||
if 'context' in kwargs:
|
"you may override `get_serializer_context` instead."
|
||||||
kwargs['context'].update(default_context)
|
)
|
||||||
else:
|
kwargs['context'] = self.get_serializer_context()
|
||||||
kwargs['context'] = default_context
|
|
||||||
|
|
||||||
return serializer_class(*args, **kwargs)
|
return serializer_class(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user