mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-25 11:33:43 +03:00
Only pass allow_empty to the ListSerializer
if it was in the arguments.
Helps with backward compatibility.
This commit is contained in:
parent
dcdd765647
commit
4404d40f60
|
@ -113,12 +113,13 @@ class BaseSerializer(Field):
|
||||||
kwargs['child'] = cls()
|
kwargs['child'] = cls()
|
||||||
return CustomListSerializer(*args, **kwargs)
|
return CustomListSerializer(*args, **kwargs)
|
||||||
"""
|
"""
|
||||||
allow_empty = kwargs.pop('allow_empty', True)
|
allow_empty = kwargs.pop('allow_empty', None)
|
||||||
child_serializer = cls(*args, **kwargs)
|
child_serializer = cls(*args, **kwargs)
|
||||||
list_kwargs = {
|
list_kwargs = {
|
||||||
'child': child_serializer,
|
'child': child_serializer,
|
||||||
'allow_empty': allow_empty,
|
|
||||||
}
|
}
|
||||||
|
if allow_empty is not None:
|
||||||
|
list_kwargs['allow_empty'] = allow_empty
|
||||||
list_kwargs.update(dict([
|
list_kwargs.update(dict([
|
||||||
(key, value) for key, value in kwargs.items()
|
(key, value) for key, value in kwargs.items()
|
||||||
if key in LIST_SERIALIZER_KWARGS
|
if key in LIST_SERIALIZER_KWARGS
|
||||||
|
|
Loading…
Reference in New Issue
Block a user