ModelSerializer requires RelatedManager field with content-type json but not with form-data #9529
Unanswered
bacheric
asked this question in
Potential Issue
Replies: 1 comment 1 reply
-
Sounds like the difference between sending an empty string in one case, and a missing field in the other perhaps? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I stumbled upon an interesting issue which caused me some hours of debugging to finally understand it.
I have two models (reduced in this example:
privacy_processing_activity.py
privacy_recipient_reference.py
Serializer:
Sending a POST request now with postman using Body: raw/json,
I get a 400 return with
If I send it as form-data instead, the serializer has no issues and the object is created and I get a 201 response.
To me it should not make a difference in that case, but the serializer obviously behaves differently. I fixed it by creating a SerializerMethodField() in the serializer since I want my api consumers to be able to use both request types.
I found a somewhat similar sounding issue here: #5807 but I don't really know if its related.
Beta Was this translation helpful? Give feedback.
All reactions