[Django] #32004: Improve documentation of request.FILES

14 views
Skip to first unread message

Django

unread,
Sep 14, 2020, 12:27:46 PM9/14/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
------------------------------------------------+------------------------
Reporter: Janos Roden | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Keywords: upload
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Regarding `request.FILES` and `multipart/form-data` requests I think it
worth to mention that the `filename` parameter of the `content-
disposition` header of the part is
[https://github.com/django/django/blob/master/django/http/multipartparser.py#L625
crutial] 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32004>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 14, 2020, 12:28:38 PM9/14/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------

Reporter: Janos Roden | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:

Keywords: upload | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Janos Roden):

* cc: Janos Roden (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:1>

Django

unread,
Sep 14, 2020, 12:36:50 PM9/14/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------

Reporter: Janos Roden | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:

Keywords: upload | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Janos Roden:

Old description:

> Regarding `request.FILES` and `multipart/form-data` requests I think it
> worth to mention that the `filename` parameter of the `content-
> disposition` header of the part is
> [https://github.com/django/django/blob/master/django/http/multipartparser.py#L625
> crutial] 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.

New description:

Regarding `request.FILES` and `multipart/form-data` requests I think it

worth to mention in the doc that the `filename` parameter of the `content-

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:2>

Django

unread,
Sep 15, 2020, 2:34:43 AM9/15/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
--------------------------------------+------------------------------------

Reporter: Janos Roden | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

HI Janos, yes OK. Very happy to look at a suggestion to the docs here.
Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:3>

Django

unread,
Sep 15, 2020, 4:55:21 AM9/15/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
--------------------------------------+------------------------------------

Reporter: Janos Roden | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Janos Roden):

Hi Carlton,

I'm thinking about [https://docs.djangoproject.com/en/3.1/topics/http
/file-uploads/#basic-file-uploads this] section:
Note that `request.FILES` will only contain data if the request method
was `POST` and the `<form>` that posted the request has the attribute
`enctype="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 was `POST` and the `<form>` that posted the request has
the attribute `enctype="multipart/form-data"` and contains at least one
`<intput type="file">` field.
Or more technically if request method was `POST`, the `Content-Type`
general header was `multipart/form-data` and the `Content-Disposition`
subpart header contains the `filename` parameter (default behavior in
browsers for this `enctype`).
Otherwise, `request.FILES` will be empty.

Feel free to correct my english, please.
I hope it isn't too complicated, what do you think?

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:4>

Django

unread,
Sep 15, 2020, 5:04:01 AM9/15/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
--------------------------------------+------------------------------------

Reporter: Janos Roden | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:5>

Django

unread,
Sep 16, 2020, 4:27:37 AM9/16/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
--------------------------------------+------------------------------------

Reporter: Janos Roden | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Janos Roden):

Okay, I created one, let's discuss how to phrase it:
https://github.com/django/django/pull/13425

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:6>

Django

unread,
Sep 16, 2020, 7:41:06 AM9/16/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------
Reporter: Janos Roden | Owner: Janos
Type: | Roden
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1

Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Janos Roden):

* owner: nobody => Janos Roden
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:7>

Django

unread,
Sep 16, 2020, 7:48:16 AM9/16/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------
Reporter: Janos Roden | Owner: Janos
Type: | Roden
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1

Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:8>

Django

unread,
Sep 22, 2020, 5:34:48 AM9/22/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------
Reporter: Janos Roden | Owner: Janos
Type: | Roden
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: upload | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:9>

Django

unread,
Sep 22, 2020, 7:28:36 AM9/22/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------
Reporter: Janos Roden | Owner: Janos
Type: | Roden
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: upload | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9e4b1ad33e436e8fe60af756d7e09639ee886ac2" 9e4b1ad]:
{{{
#!CommitTicketReference repository=""
revision="9e4b1ad33e436e8fe60af756d7e09639ee886ac2"
Fixed #32004 -- Clarified docs for when request.FILES is set.

Co-authored-by: Carlton Gibson <carlton...@noumenal.es>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:10>

Django

unread,
Sep 22, 2020, 7:29:25 AM9/22/20
to django-...@googlegroups.com
#32004: Improve documentation of request.FILES
-------------------------------------+-------------------------------------
Reporter: Janos Roden | Owner: Janos
Type: | Roden
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.1

Severity: Normal | Resolution: fixed
Keywords: upload | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"1d7c4addbdf7b90684a6464a21afb8f48019d338" 1d7c4add]:
{{{
#!CommitTicketReference repository=""
revision="1d7c4addbdf7b90684a6464a21afb8f48019d338"
[3.1.x] Fixed #32004 -- Clarified docs for when request.FILES is set.

Co-authored-by: Carlton Gibson <carlton...@noumenal.es>

Backport of 9e4b1ad33e436e8fe60af756d7e09639ee886ac2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32004#comment:11>

Reply all
Reply to author
Forward
0 new messages