VOOZH about

URL: https://www.geeksforgeeks.org/python/make-pwa-of-a-django-project/

⇱ Make PWA of a Django Project - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Make PWA of a Django Project

Last Updated : 15 Jul, 2025

Progressive Web Apps (PWAs) are web applications built using standard web technologies that can be installed on devices like native apps, providing offline capabilities, push notifications, and faster loading.

Prerequisites:

A django project that is ready to be deployed.

The below steps have to be followed to create a progressive web application of a Django project.

Install django-pwa

Install the django-pwa package which simplifies the PWA integration:

pip install django-pwa

Configure Django Settings

1. In your settings.py, add 'pwa' to the INSTALLED_APPS list:

INSTALLED_APPS = [
...
'pwa',
]

2. Also, add the path for the service worker (you'll create this later):

3. Add your PWA settings to settings.py to generate the manifest.json automatically. Customize the values as per your app:

Update urls.py

Include the pwa app URLs in your project's urls.py:

👁 urlsPyDjangoPWA
URLS.py

This will expose necessary URLs like /manifest.json and /serviceworker.js.

Create the Service Worker

Create a folder static/js inside your Django project if it doesn't exist. Inside static/js, create a file called serviceworker.js and add the following code:

Add PWA Meta Tags in Templates

In your base template or the main page template (e.g., index.html), add the following at the top to load PWA tags:

👁 htmlDjangoPWA
Meta Tags

This will automatically add the manifest and service worker registration scripts in your HTML.

Test Your PWA

1. Run your Django development server:

python manage.py runserver

2. Open your site in Chrome or any modern browser.

3. Open Developer Tools (F12 or right-click → Inspect).

4. Go to the Application tab:

  • Verify that the Manifest is loaded.
  • Verify that the Service Worker is registered and active.
👁 DjangoServiceWorker
Django Development Server
👁 ServiceWorker
Service Wroker

5. Our PWA is ready to be installed now. You will see the install icon in the address tab.

👁 DjangoPWA
Django PWA
Comment
Article Tags: