Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33048 closed Cleanup/optimization (fixed)

Documentation doesn't mention that using staticfiles' runserver doesn't use the middleware chain.

Reported by: Keryn Knight Owned by: valleyofblackpanther
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: 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

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 โ€‹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) ;)

Change History (7)

comment:1 by Carlton Gibson, 3 years ago

Triage Stage: Unreviewed โ†’ Accepted

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...? ๐Ÿ˜œ)

comment:2 by valleyofblackpanther, 3 years ago

Owner: changed from nobody to valleyofblackpanther
Status: new โ†’ assigned

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

Version 0, edited 3 years ago by valleyofblackpanther (next)

comment:3 by valleyofblackpanther, 3 years ago

Has patch: set

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.

comment:4 by Carlton Gibson, 3 years ago

Patch needs improvement: set

comment:5 by Mariusz Felisiak, 3 years ago

Patch needs improvement: unset
Triage Stage: Accepted โ†’ Ready for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@โ€ฆ>, 3 years ago

Resolution: โ†’ fixed
Status: assigned โ†’ closed

In 1625a8c8:

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

comment:7 by Mariusz Felisiak <felisiak.mariusz@โ€ฆ>, 3 years ago

In f4de8703:

[4.0.x] Fixed #33048 -- Doc'd that DEBUG static files requests don't use middleware chain.

Backport of 1625a8c8eba0b00ebdd1d7a8ba697b2729ec40ed from main

Note: See TracTickets for help on using tickets.
Back to Top