Skip to content

Commit b29ec84

Browse files
author
Pierre Chiquet
committed
Separated run_child_validation method in ListSerializer
1 parent 61e7a99 commit b29ec84

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
@@ -614,6 +614,17 @@ def run_validation(self, data=empty):
614614

615615
return value
616616

617+
def run_child_validation(self, data):
618+
"""
619+
Run validation on child serializer.
620+
You may need to override this method to support multiple updates. For example:
621+
622+
self.child.instance = self.instance.get(pk=data['id'])
623+
self.child.initial_data = data
624+
return super().run_child_validation(data)
625+
"""
626+
return self.child.run_validation(data)
627+
617628
def to_internal_value(self, data):
618629
"""
619630
List of dicts of native values <- List of dicts of primitive datatypes.
@@ -640,7 +651,7 @@ def to_internal_value(self, data):
640651

641652
for item in data:
642653
try:
643-
validated = self.child.run_validation(item)
654+
validated = self.run_child_validation(item)
644655
except ValidationError as exc:
645656
errors.append(exc.detail)
646657
else:

0 commit comments

Comments
 (0)