-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
ManyToMany not validated when sending form-data instead of JSON #2249
Comments
Hiya, thanks for raising this. Could you give some more detailed information. What do we need to do to replicate this? What 'errors' are being raised for JSON but not for form-data? Are you able to reproduce in a test case? |
There you go. if you try with JSON |
I'd believe what you're seeing is because on the form submission the eg. try overriding
So you can see what data is being submitted. Welcome to reopen the issue if you think that's not correct or needs further explanation. We could consider an |
I printed the data in the create method in my view. But I also tried. Printing in the serializer`s create method.
and that gave me |
Ah apologies, what you're seeing is slightly different that how I described it before.
Hope that helps explain what you're seeing. Don't believe there's any way around that. Follow up question is do you want to allow an empty list as a valid submission or not? |
I get it now. To answer your question. No I don't want to allow empty lists. So yes I need the data to be validated correctly. Both when I don't send the |
Related issue #2250 now created. In the meantime you could use a
|
Thanks for working through the issue. Hope this helps. |
Thanks a lot! And if you did decide to add the |
Hello,
In 3.0
I have a model serializer and the model have required ManyToMany fields.
When I'm sending data as
application/json
it's validating that some of the ManyToMany fields aren't present and it throws the correct errors.But when I send them using
multipart/form-data
it's not validating the ManyToMany fields. It would actually create the object without any ManyToMany fields.Not sure if this behavior is intended or not.
The text was updated successfully, but these errors were encountered: