#32004 closed Cleanup/optimization (fixed)
Improve documentation of request.FILES
Reported by: | Janos Roden | Owned by: | Janos Roden |
---|---|---|---|
Component: | Documentation | Version: | 3.1 |
Severity: | Normal | Keywords: | upload |
Cc: | Janos Roden | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Regarding request.FILES
and multipart/form-data
requests I think it worth to mention in the doc that the filename
parameter of the content-disposition
header of the part is βcrucial to handle the part as a file.
I used a low level library to generate requests and I thought Django will use a temporary file (and file name) for this content.
Of course after I found out how it works it's make sense, but read about it in the docs would have help me to fix my code much quicker.
Change History (11)
comment:1 by , 4 years ago
Cc: | added |
---|
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
comment:3 by , 4 years ago
Triage Stage: | Unreviewed β Accepted |
---|
comment:4 by , 4 years ago
Hi Carlton,
I'm thinking about βthis section:
Note that
request.FILES
will only contain data if the request method wasPOST
and the<form>
that posted the request has the attributeenctype="multipart/form-data"
. Otherwise,request.FILES
will be empty.
Could be extended as
Note that
request.FILES
will only contain data from form fields if the request method wasPOST
and the<form>
that posted the request has the attributeenctype="multipart/form-data"
and contains at least one<intput type="file">
field.
Or more technically if request method wasPOST
, theContent-Type
general header wasmultipart/form-data
and theContent-Disposition
subpart header contains thefilename
parameter (default behavior in browsers for thisenctype
).
Otherwise,request.FILES
will be empty.
Feel free to correct my english, please.
I hope it isn't too complicated, what do you think?
comment:5 by , 4 years ago
Hi Janos. First glance seems a bit π¬: the point is the Content-Disposition
header right? But how do we state that in the context of form submission... βΒ yes, via the input... βΒ Can you open a PR, and we discuss there? (It's much easier to review and suggest changes there.) Thanks.
comment:6 by , 4 years ago
Okay, I created one, let's discuss how to phrase it: βhttps://github.com/django/django/pull/13425
comment:7 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new β assigned |
comment:8 by , 4 years ago
Has patch: | set |
---|
comment:9 by , 4 years ago
Triage Stage: | Accepted β Ready for checkin |
---|
HI Janos, yes OK. Very happy to look at a suggestion to the docs here. Thanks.