mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 12:12:19 +03:00
Update rest_framework/serializers.py
Co-authored-by: Sergei Shishov <sshishov@users.noreply.github.com>
This commit is contained in:
parent
bb4102a162
commit
0dc62010b1
|
@ -610,9 +610,11 @@ class ListSerializer(BaseSerializer):
|
||||||
assert self.child is not None, '`child` is a required argument.'
|
assert self.child is not None, '`child` is a required argument.'
|
||||||
assert not inspect.isclass(self.child), '`child` has not been instantiated.'
|
assert not inspect.isclass(self.child), '`child` has not been instantiated.'
|
||||||
|
|
||||||
if kwargs.get('instance', []) and kwargs.get('data', []):
|
# instance, data = kwargs.get('instance', []), kwargs.get('data', []) # if you prefer one line assignment support
|
||||||
assert len(kwargs.get("data", [])) == len(
|
instance = kwargs.get('instance', [])
|
||||||
kwargs.get("instance", [])), 'Data and instance should have same length'
|
data = kwargs.get('data', [])
|
||||||
|
if instance and data:
|
||||||
|
assert len(data) == len(instance), 'Data and instance should have same length'
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.child.bind(field_name='', parent=self)
|
self.child.bind(field_name='', parent=self)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user