Skip to content

Commit

Permalink
Separated run_child_validation method in ListSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Chiquet committed May 10, 2022
1 parent cdc956a commit 2026e19
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rest_framework/serializers.py
Expand Up @@ -625,6 +625,17 @@ def run_validation(self, data=empty):

return value

def run_child_validation(self, data):
"""
Run validation on child serializer.
You may need to override this method to support multiple updates. For example:
self.child.instance = self.instance.get(pk=data['id'])
self.child.initial_data = data
return super().run_child_validation(data)
"""
return self.child.run_validation(data)

def to_internal_value(self, data):
"""
List of dicts of native values <- List of dicts of primitive datatypes.
Expand Down Expand Up @@ -663,7 +674,7 @@ def to_internal_value(self, data):

for item in data:
try:
validated = self.child.run_validation(item)
validated = self.run_child_validation(item)
except ValidationError as exc:
errors.append(exc.detail)
else:
Expand Down

0 comments on commit 2026e19

Please sign in to comment.