#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 , 3 years ago
Triage Stage: | Unreviewed โ Accepted |
---|
comment:3 by , 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 , 3 years ago
Patch needs improvement: | set |
---|
comment:5 by , 3 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted โ Ready for checkin |
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. โฆ
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...? ๐)