Setup guide · Django
Turn a Django app into an installable PWA (2026)
Django 4+ PWA setup — manifest via static/, service worker at the origin root and install prompt.
Key takeaways
- Serve `sw.js` from the origin root via a Django URL pattern, not `/static/`.
- Link the manifest from your base template with `{% static %}`.
- InstantPWA handles the iOS install flow.
Before you start
- Django 4+
- HTTPS origin
- WhiteNoise or S3 for statics
manifest.webmanifest
{
"name": "Your product",
"short_name": "Product",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#111827",
"icons": [
{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
]
}Step-by-step for Django
- Step 1Add the files
Create `static/manifest.webmanifest` and `static/sw.js`.
- Step 2Serve sw.js from the root
Add a URL that returns the SW with the correct Content-Type.
# urls.py from django.views.static import serve from django.urls import path from django.conf import settings urlpatterns += [path('sw.js', serve, {'document_root': settings.STATIC_ROOT, 'path': 'sw.js'})] - Step 3Link + register
Update `base.html` to link the manifest and register `/sw.js`.
- Step 4Add the install popup
Paste the InstantPWA snippet before `</head>`.
Minimal sw.js
// public/sw.js
self.addEventListener('install', (e) => self.skipWaiting());
self.addEventListener('activate', (e) => self.clients.claim());
self.addEventListener('fetch', () => {});Common Django gotchas
- Run `collectstatic` after editing the SW or the file will 404 in production.
- Set `SECURE_SSL_REDIRECT = True` — Chrome refuses to install without HTTPS.
FAQ
Do I need a native app if my Django site is a PWA?
No. Once your Django site meets the three PWA criteria (HTTPS, a manifest, a service worker), Chromium browsers offer to install it and iOS Safari 16.4+ supports the full standalone experience — including web push.
Will a service worker slow my Django site down?
Not measurably on first load. The worker installs asynchronously after the page becomes interactive. On repeat visits it typically improves LCP and TTFB because assets are served from cache.
Can I still deploy my Django site to Vercel, Netlify or Cloudflare?
Yes. Any static or edge host works — the manifest and service worker are plain files served from the origin. No build-time integration is required.
Skip the setup — drop in one line
InstantPWA handles the install prompt across iOS, Android and desktop. Free forever for one popup.
Get started free