Is request.data truly immutable?
#8867
Unanswered
roozmr
asked this question in
Potential Issue
Replies: 1 comment 2 replies
-
|
I found a previous closed issue #7633 addressing this problem. But I am using the latest DRF version and issue still persists. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am developing a POST API in which I send
multipart/form-datacontent including an optional file field in request body.Testing the API, I sent only text data in form fields and I encountered an error trying to add an extra field (like the code below) to
request.datasaying thatThis QueryDict instance is immutableand by Querydict it meansrequest.data.But when I include files in form, API works without an error.
I traced the error and it seems when files are included in
request.data, therequest'sself._mutableis True while it is False when files are not included.In the screen shot below from
django.http.request.QueryDict,AttributeErroris raised as I did not inlcude any files.In the next one raise statement is bypassed for
self._mutableis True (attachments attribute includesInMemoryUploadedFiles).So, which one is the desired output?
Beta Was this translation helpful? Give feedback.
All reactions