I plan to convert the django project to a Progressive Web App. I cannot figure out where to place the service_worker.js and manifest.json files in my django project. I tried the following:
Myproject /
|__app1 |__app2 |__manage.py |__manifest.json |__service_worker.js
and then tried to register the service worker from the html file using the relative path .. /../../service_worker.js. This did not work. He showed this error: "Upon receipt of the script."
HTTP error code (404) was received
Another approach I tried is to put service_worker.js and manifest.json in the static folders:
Myproject /
|__app1/ |__static/ |__app1/ |__service_worker.js |__manifest.json |__app2 |__manage.py
and access them using {% static 'app1 / service_worker.js'%}. The problem with this approach is that the scope of the registered service_worker.js is limited to this static folder. I saw in one stackoverflow answer that I can explicitly specify the working worker area as {scope: '/'}. But I think there may be a better approach that I am missing. Please let me know if anyone has a solution.
source share