[Django] #33048: Documentation doesn't mention that using staticfiles' runserver doesn't use the middleware chain.

18 views
Skip to first unread message

Django

unread,
Aug 24, 2021, 8:16:21 AM8/24/21
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
------------------------------------------------+------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
I'm not sure ''why'' it doesn't use the middleware chain (but then I don't
really know why it's not a middleware itself), because it makes a certain
class of development tooling (ie: tracking responses which are assets)
more difficult (I think I might have to monkeypatch? ugh), but hey ho.

It would be nice if there were an admonition in
[https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-
files-during-development the Serving static files during development docs]
to say as much, especially given that if you ''don't'' have
`django.contrib.staticfiles` in your `INSTALLED_APPS` and instead have
opted for using `+= static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT)` for whatever reason, those requests
**do** go through the middleware chain.

Perhaps worth noting that the subject came up independently in #32891 and
despite reading that thread, I'd entirely forgotten that `staticfiles` was
abnormal in that respect, in just 8 weeks...

Of course, I'm also open to changing it to go through the middleware chain
like a normal request (which would look to involve removing `get_response`
in favour of `resolve_request` ... or just changing it to be a middleware)
;)

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

Django

unread,
Aug 24, 2021, 8:53:07 AM8/24/21
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
--------------------------------------+------------------------------------

Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | 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:

Hey Keryn. 😀

Having been confused on #32891, I agree that this is confusing. (X
weeks/months/years since I thought about this, why doesn't it work the
same as everything else… 🤔. Repeat.)

If you want to document this, super. …

> Of course, I'm also open to changing it to go through the middleware

chain like a normal request ...

Sketching that up as a proposal would likely be worth a discussion on the
DevelopersMailingList (I mean that's on the road to #27325 no...? 😜)

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

Django

unread,
Dec 3, 2021, 9:26:20 PM12/3/21
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
Type: | valleyofblackpanther
Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev

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

* owner: nobody => valleyofblackpanther
* status: new => assigned


Comment:

This is more than an edit on the document. We have to consider various
interconnected technical issues.

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

Django

unread,
Dec 5, 2021, 10:06:32 PM12/5/21
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
Type: | valleyofblackpanther
Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev

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

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

* has_patch: 0 => 1


Comment:

Hi everyone. I am Kaushik. So you can see that from the ticket that it
needed some edit on the documentation, and I did the needed refraction to
it. I added a note to the documentation explaining the role of middleware
during serving the static files, explaining the role of runserver and how
it overrides per se, and how it doesn't run MIDDLEWARE. The documentation
is well versed but it didn't mention anything about the middleware
function. This note will help first-time readers to give them an
insightful mechanism of how it automatically serves static files. This is
my first pull request during my Django contribution
[https://github.com/django/django/pull/15159] If you have anything to add
to it or feel like it doesn't make any sense kind of feeling, mention it
below the comments, we'll try to negotiate and come to terms where it will
serve both our interests to the contribution.

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

Django

unread,
Dec 10, 2021, 5:16:00 AM12/10/21
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
Type: | valleyofblackpanther
Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


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

Django

unread,
Jan 25, 2022, 5:12:40 AM1/25/22
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
Type: | valleyofblackpanther
Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | 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 Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


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

Django

unread,
Jan 26, 2022, 6:03:06 AM1/26/22
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
Type: | valleyofblackpanther
Cleanup/optimization | Status: closed
Component: Documentation | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | 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 Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"f4de87038ef3adfe8c67ede6c3c5519451abe6cc" f4de8703]:
{{{
#!CommitTicketReference repository=""
revision="f4de87038ef3adfe8c67ede6c3c5519451abe6cc"
[4.0.x] Fixed #33048 -- Doc'd that DEBUG static files requests don't use
middleware chain.

Backport of 1625a8c8eba0b00ebdd1d7a8ba697b2729ec40ed from main
}}}

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

Django

unread,
Jan 26, 2022, 6:03:06 AM1/26/22
to django-...@googlegroups.com
#33048: Documentation doesn't mention that using staticfiles' runserver doesn't use
the middleware chain.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
Type: | valleyofblackpanther
Cleanup/optimization | Status: closed
Component: Documentation | Version: dev

Severity: Normal | Resolution: fixed
Keywords: | 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 Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"1625a8c8eba0b00ebdd1d7a8ba697b2729ec40ed" 1625a8c8]:
{{{
#!CommitTicketReference repository=""
revision="1625a8c8eba0b00ebdd1d7a8ba697b2729ec40ed"


Fixed #33048 -- Doc'd that DEBUG static files requests don't use
middleware chain.
}}}

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

Reply all
Reply to author
Forward
0 new messages