Closed ses4j closed 2 years ago
~Which version are you using? If I try this in the REPL, it seems to work as expected:~ Ah, no, I see what you mean. That looks like a bug, indeed.
The root cause is this check, which triggers for a QueryDict
but doesn't for a regular one.
https://github.com/encode/django-rest-framework/blob/54d52c66fd221e9ff86d8b428c6c0178c0501606/rest_framework/fields.py#L422-L428
It seems that DRF assumes a missing value in a QueryDict
is None
or False
. You can workaround it by setting the partial=True
option, to only consider fields that are present.
Ah, interesting. That's true, though I then lose validation on required params.
I don't think there's anything we can do about this, as this is caused by behaviour of DRF and is not specific to the DataclassSerializer, so I'll close this issue. You can workaround it by converting the QueryDict
to a regular dict using the dict()
method.
If you pass a QueryDict to a serializer (such as request.GET), the bool somehow loses it's default value.
Demonstration: