用于在django项目中添加渐进式web应用程序功能的库。
django-progressive的Python项目详细描述
django pwa公司
用于在django项目中添加渐进式web应用程序功能的库。在
目录
简介
这个Django库在Django项目中添加了progressive web app功能。在
当您从移动浏览器打开站点时,将提示您将站点作为应用程序添加到主屏幕。在
安装
pip install django-progressive
配置
将django progressivedjango_pwa
添加到已安装的应用程序INSTALLED_APPS
在django settings.py
定义STATICFILES_DIRS
在settings.py
中,使用前缀PWA碜和来自{a7}的键
您可以配置pwa清单。在
PWA_NAME='test app'PWA_SHORT_NAME='test_app'PWA_ICONS=[{"src":"/static/icons/icon-128x128.png","sizes":"128x128","type":"image/png"},{"src":"/static/icons/icon-144x144.png","sizes":"144x144","type":"image/png"},{"src":"/static/icons/icon-152x152.png","sizes":"152x152","type":"image/png"},{"src":"/static/icons/icon-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/static/icons/icon-256x256.png","sizes":"256x256","type":"image/png"},{"src":"/static/icons/icon-512x512.png","sizes":"512x512","type":"image/png"}]
您可以使用
PWA_WORKER_LOCATION
。在
PWA_WORKER_LOCATION=join('static','django_pwa_demo','service-worker.js')
使用
将django_pwa
url添加到您的urls.py
fromdjango.urlsimportpath,includeurlpatterns=['...',path('',include('django_pwa.urls')),'...']
您可以添加{% load pwa_extras %}
以使用{% load_manifest %}
模板标记来加载manifest.json
和{worker-app.js
。在
{% load pwa_extras %} <!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>PWA Test</title> {% load_manifest %} </head><body><h1>Hello world!!!</h1> {% load_worker %} </body></html>
链接
- 项目
标签: