django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

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

Open em1208 opened this issue 3 years ago • 3 comments

…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 avatar Aug 30 '22 01:08 em1208

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.

em1208 avatar Aug 30 '22 04:08 em1208

@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.

em1208 avatar Nov 26 '22 20:11 em1208