Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Two reproducible issues in DRF nested serializers with many to many t… #8627

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

em1208
Copy link

@em1208 em1208 commented Aug 30, 2022

…hrough model

Note: Before submitting this pull request, please review our contributing guidelines.

Description

I have found two issues when working on a nested serializer with many to many with through model. The first one is related on how APIClient prepare the request with nested json using multipart/form-data which is not passed as json to request.data, so in this case the serializer raises, complaining about missing items which is actually passed. The second one is related on how to_representation is called which is raising an attribute error. Any help to find the root cause of these two issues would be much appreciated.

@em1208
Copy link
Author

em1208 commented Aug 30, 2022

I managed to fix the to_representation issue by specifying the source parameter on the many to many serializer but there is still an issue on the default json encoding.

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my questions,
were you able to fix many to many through model issue in DRF? also the name of test app as issue is quite ambigous, do you have any better name in mind? or can we add proposed tests to exiting tests/test apps?

@em1208
Copy link
Author

em1208 commented Nov 26, 2022

@auvipy I believe there is a problem with APIClient but I didn't dig further into it so I can't point precisely what is causing the issue. The many to many serializer issue does not appear as long as the source parameter is specified, I think the documentation should be clear about it. I'll be happy to rename the test app to something else, if you have any preference let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants