Skip to content

Commit 2026e19

Browse files
author
Pierre Chiquet
committed
Separated run_child_validation method in ListSerializer
1 parent cdc956a commit 2026e19

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

rest_framework/serializers.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,17 @@ def run_validation(self, data=empty):
625625

626626
return value
627627

628+
def run_child_validation(self, data):
629+
"""
630+
Run validation on child serializer.
631+
You may need to override this method to support multiple updates. For example:
632+
633+
self.child.instance = self.instance.get(pk=data['id'])
634+
self.child.initial_data = data
635+
return super().run_child_validation(data)
636+
"""
637+
return self.child.run_validation(data)
638+
628639
def to_internal_value(self, data):
629640
"""
630641
List of dicts of native values <- List of dicts of primitive datatypes.
@@ -663,7 +674,7 @@ def to_internal_value(self, data):
663674

664675
for item in data:
665676
try:
666-
validated = self.child.run_validation(item)
677+
validated = self.run_child_validation(item)
667678
except ValidationError as exc:
668679
errors.append(exc.detail)
669680
else:

0 commit comments

Comments
 (0)