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-data
content 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.data
saying thatThis QueryDict instance is immutable
and 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._mutable
is True while it is False when files are not included.In the screen shot below from
django.http.request.QueryDict
,AttributeError
is raised as I did not inlcude any files.In the next one raise statement is bypassed for
self._mutable
is True (attachments attribute includesInMemoryUploadedFile
s).So, which one is the desired output?
Beta Was this translation helpful? Give feedback.
All reactions