[Django] #32379: Documentation: hypercorn and static files

67 views
Skip to first unread message

Django

unread,
Jan 22, 2021, 11:31:17 AM1/22/21
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-----------------------------------------------+------------------------
Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 3.1
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 |
-----------------------------------------------+------------------------
Coming from the age-old problem of service static files, the usual process
looks like this:

1) ✅develop and test using {{{ manage.py runserver }}} and everything
just works fine
2) ✅ deploy code using WSGI or ASGI as described in the docs
3) ❌ find out that static files are missing

Specifically referring to
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/hypercorn/

As there is a dedicated documentation page for hypercorn, it doesn't look
like there's a need for thinking of serving static files.

A friend of mine suggested to use whitenoise:
https://github.com/evansd/whitenoise

Would it make sense to integrate this into the Django docs?


To be transparent here, I started also different threads on different
channels but it seems like nobody really wants to tackle this issue, so I
thought addressing the issue at least via Django sounds reasonable because
it's a Web framework:
here: https://softwarerecs.stackexchange.com/questions/77600/simple-and-
secure-command-line-http-server
and there: https://gitlab.com/pgjones/hypercorn/-/issues/173
from another guy: https://gitlab.com/pgjones/hypercorn/-/issues/45

As of now, I addressed my real-world setup by setting up a "mini"-nginx
for now, serving static files and proxying hypercorn, but that does not
feel like a holistic solution; also when it comes to automated deployment,
permissions, principles such as "test as you fly, fly as you test" etc.
it's a lot more brittle.

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

Django

unread,
Jan 25, 2021, 2:00:36 AM1/25/21
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-------------------------------------+-------------------------------------

Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 3.1
Severity: Normal | Resolution:

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

* cc: Carlton Gibson (added)


Comment:

> Would it make sense to integrate this into the Django docs?

See #27325.

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

Django

unread,
Jan 26, 2021, 2:55:12 AM1/26/21
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-------------------------------------+-------------------------------------

Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.staticfiles | Version: 3.1
Severity: Normal | Resolution: duplicate

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

* status: new => closed
* resolution: => duplicate


Comment:

Hi Sven. Not really sure what to say here.

I think it's a reasonable assumption that by the time you're deploying
with ASGI you've already established your strategy for handling static
files (or, at least, are intimately aware of the wiggles).

If you're just thinking about development, then we have #31626 to add
support for ASGI to runserver. Until then, I think it's up to the
individual servers (or users of those) to provide a static files solution.
Channels provides a `runserver` implementation, including a static files
middleware precisely for this.

Then, deploying behind nginx is the Standard Solution™ (if there is one) —
you're are always meant to deploy Django behind a proxy, since protocol
servers (Gunicorn, uWSGI, Daphne, uvicorn, etc) all expect that. (Why?
Because they're deliberately not battle hardened to be exposed to the
internet.)

Given that, having nginx serve your static files is the natural move.
("natural" and "holistic", whilst clearly not cognates, inhabit a close
enough space I'd say. :)

This topic comes up on the DevelopersMailingList a couple of times a year
I'd say. My summary would be that there are so many options and opinions
on how to do it that we never reach anything close to a consensus for a
new feature. `contrib.staticfiles`'s `collectstatic` works well but what
you do beyond that seems to be out of scope for Django itself.

Closing as a duplicate of #27325 — but TBH I'm not even sure there's
really consensus for merging that. (There may be, with sufficient opt-
outs...)

Hope that's sufficiently explanatory. It would be nice if it were simpler
I do grant, but after all this time we're still lacking a proposal that
folks agree on as an improvement…

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

Django

unread,
May 18, 2021, 3:04:14 PM5/18/21
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-------------------------------------+-------------------------------------

Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.staticfiles | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* resolution: duplicate => fixed


Comment:

In [changeset:"8cd55021bcb6c9727c1adccd9623fa4acfc0312b" 8cd55021]:
{{{
#!CommitTicketReference repository=""
revision="8cd55021bcb6c9727c1adccd9623fa4acfc0312b"
Fixed #32379 -- Started deprecation toward changing default USE_TZ to
True.

Co-authored-by: Nick Pope <ni...@nickpope.me.uk>
Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>
}}}

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

Django

unread,
May 18, 2021, 3:05:31 PM5/18/21
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-------------------------------------+-------------------------------------

Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.staticfiles | Version: 3.1
Severity: Normal | Resolution: duplicate

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

* resolution: fixed => duplicate


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

Django

unread,
May 25, 2021, 7:23:21 AM5/25/21
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-------------------------------------+-------------------------------------

Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.staticfiles | Version: 3.1
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"7e51893911237dfca9294e3ca12163ff813fb656" 7e518939]:
{{{
#!CommitTicketReference repository=""
revision="7e51893911237dfca9294e3ca12163ff813fb656"
Refs #32379 -- Added USE_TZ settings to
AdminScriptTestCase.write_settings().
}}}

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

Django

unread,
Jan 17, 2023, 5:49:43 AM1/17/23
to django-...@googlegroups.com
#32379: Documentation: hypercorn and static files
-------------------------------------+-------------------------------------

Reporter: Sven R. Kunze | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.staticfiles | Version: 3.1
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"602d9a312facc64d44619c61c3863d3d0820006a" 602d9a3]:
{{{
#!CommitTicketReference repository=""
revision="602d9a312facc64d44619c61c3863d3d0820006a"
Refs #32379 -- Changed default USE_TZ to True.

Per deprecation timeline.
}}}

Reply all
Reply to author
Forward
0 new messages