feat: add django-whitenoise

This commit is contained in:
2026-07-14 20:29:29 +02:00
parent 9a795dc3c9
commit f986105cf5
8 changed files with 73 additions and 5 deletions
+20
View File
@@ -34,6 +34,26 @@ DJANGO_CSRF_TRUSTED_ORIGINS=http://192.168.1.x:8000 uv run python manage.py runs
Sessions last a year, so your phone stays logged in.
## Static files
WhiteNoise serves `/static/` from Django itself, so there is no nginx or S3 to
set up. `collectstatic` hashes every file's contents into its name and writes
gzip/brotli copies alongside, and WhiteNoise serves those with a ten-year
immutable cache header — worth having on a phone over a slow connection.
```bash
uv run python manage.py collectstatic --noinput
```
Run that whenever an icon or CSS file changes. In `DEBUG=1` Django serves the
files directly and you can skip it; with `DEBUG=0` the hashed manifest must
exist or pages referencing `{% static %}` will fail.
`manifest.webmanifest` and `sw.js` are templates rather than static files: the
manifest so `{% static %}` resolves the icons to their hashed names (the
staticfiles storage only rewrites URLs inside CSS and JS), and the worker
because it has to be served from `/` to control the `/admin/` pages it caches.
## Installing it on Android (PWA)
The Today page is a progressive web app: Chrome will offer *Add to home screen*