failing test: #4936
When using a ModelSerializer for a model with a ManyToMany field, and applying required=False to that field in extra_kwargs, omitting the ManyToManyField in the data results in a validation error ("This list may not be empty.") for form data requests (including from the browsable api form), but not for JSON requests.
On closer inspection, I found that when using the serializer directly, passing a dict, the validation error doesn't appear; whereas when passing a QueryDict it does.
Checklist
Steps to reproduce
I created a toy project to reproduce the bug.
Expected behavior
The validation shouldn't differ between form data requests and JSON requests. Because the field has the option required=False, omitting the field shouldn't prevent deserialization; thus the JSON behaviour is correct.
Actual behavior
When passing the data in a dict, omitting the many to many field ('tags' in the toy project linked above), the data passes validation; whereas passing a QueryDict (or making a request with form data rather than json) results in a validation error with message "This list may not be empty."
failing test: #4936
When using a ModelSerializer for a model with a ManyToMany field, and applying
required=Falseto that field inextra_kwargs, omitting the ManyToManyField in the data results in a validation error ("This list may not be empty.") for form data requests (including from the browsable api form), but not for JSON requests.On closer inspection, I found that when using the serializer directly, passing a
dict, the validation error doesn't appear; whereas when passing aQueryDictit does.Checklist
masterbranch of Django REST framework.Steps to reproduce
I created a toy project to reproduce the bug.
Expected behavior
The validation shouldn't differ between form data requests and JSON requests. Because the field has the option
required=False, omitting the field shouldn't prevent deserialization; thus the JSON behaviour is correct.Actual behavior
When passing the data in a dict, omitting the many to many field ('tags' in the toy project linked above), the data passes validation; whereas passing a QueryDict (or making a request with form data rather than json) results in a validation error with message "This list may not be empty."