-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Allow to override child.run_validation call in ListSerializer #8035
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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. |
b29ec84
to
8649055
Compare
8649055
to
2026e19
Compare
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these changes. They could enable third party apps to create writable nested list serializers concisely.
There was a PR to add that functionality to the core, but it was decided that extensions should take care of it. I think it's reasonable to decouple this method to help extend this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
2026e19
to
08c3e59
Compare
I have just added a simple test with a ListSerializer that overrides
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am considering accepting this on the ground of letting the 3rd party extensions to override it. do we need additional documentation?
@pchiquet should we consider some documentation update for this? |
…#8035) * Separated run_child_validation method in ListSerializer * fix typo * Add test_update_allow_custom_child_validation --------- Co-authored-by: Pierre Chiquet <pierre.chiquet@ubikey.fr>
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
initial_data
not as expected with many=True #5345