django-rest-framework
django-rest-framework copied to clipboard
Allow to override child.run_validation call in ListSerializer
Description
Move child.run_validation() call to a separated method: ListSerializer.run_child_validation.
This allows to easily customize this behavior without overriding ListSerializer.to_internal_value (which duplicates rest_framework code).
It is useful to support multiple updates where child.instance should be set during run_validation (else a queryset or a list of instances is passed to child serializer).
See
- https://github.com/encode/django-rest-framework/discussions/7805 / https://github.com/encode/django-rest-framework/issues/6130
- https://github.com/encode/django-rest-framework/issues/5345
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
OK I guess this can be accepted to let 3rd party ext to add custom functionality. but would be great if we can add some tests
I have just added a simple test with a ListSerializer that overrides run_child_validation.
- without this custom implementation,
self.instanceandself.initial_dataare lists during child serializer validation. - run_child_validation allows to set
self.instanceto current instance andself.initial_datato current update data.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@pchiquet should we consider some documentation update for this?