silviolleite / django-pwa Goto Github PK
View Code? Open in Web Editor NEWLooks like an app, feels like an app, but IS NOT an app.
License: MIT License
Looks like an app, feels like an app, but IS NOT an app.
License: MIT License
How to prevent django-pwa from writing django-pwa: ServiceWorker registration successful with scope?
pwa/urls.py
uses the deprecated url()
function instead of its newer replacement:
RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path()
hi, i have the error in the issue name, i have
Successfully installed asgiref-3.2.7 django-3.0.6 django-pwa-1.0.8 pytz-2020.1 sqlparse-0.3.1
Hello i'm using django cookie cutter and bucket type for distribue static and media files (aws s3,google storage,etc..), after some reading, i'm using workbox (google workbox) for the easing caching.
for avoid the opaque responses, it's advised add crossorigin=anonymous in all img and link (https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests) and the opaque responses no put always files in cache.
It's possible add option for add crossorigin anonymous (add in link) in head your generate with the tags.
Personal question and good use of the service worker:
When i generate my docker, i use gulps for modify variable CACHE_VERSION in serviceworkers.js ( example : cacheName: 'js-cache-' + CACHE_VERSION) for add new number version. so that i force reload cache in navigator and reload new cache if new docker is build. it is good usage for pwa ?
Thanks in advance
Tried djanog-pwa today, and found that the service worker would not register. Investigations suggest that the cause is re-directs generated by i18n (from root to, e.g. /en/).
Hi!
Before all: thanks for doing everything! 😄
I'm trying to install the package on my website, and I'm following the readme.md
On THIS part of the readme, you are doing:
from django.urls import url, include
urlpatterns = [
...
url('', include('pwa.urls')), # You MUST use an empty string as the URL prefix
...
]
But I don't know if I'm doing something wrong (I'm don't know python perfectly) but including your snipper (aka the url inside urlpatterns in the main app/urls.py) gave me this error:
ImportError: cannot import name 'url' from 'django.urls'
Because I usually include a "path" and not an "url" inside "urlpatterns" list, and I saw that in your demo you done the same, I've changed it in a more familiar:
urlpatterns = [
...
path('', include('pwa.urls')), # You MUST use an empty string as the URL prefix
...
]
And is working.
Is the readme.md wrong or there's something I didn't get in django, python or django-pwa?
Hi there thanks for the awesome project.
I am trying to add this application to a Divio project and am getting a ModuleNotFoundError: No module named 'pypandoc'.
I think this may be because Divio is using docker and the with that particular image pip is trying to build the package and pandoc is not available (It is not available on the repo in the image, I could probably work around this and install it).
My question is what was the initial purpose of catching the RuntimeError below and would you be happy I make a PR that catches both RuntimeError and ModuleNotFoundError?
setup.py
# noinspection PyBroadException
try:
# noinspection PyPackageRequirements
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except RuntimeError:
long_description = short_description
Hey guys!
I've been using this on my website https://sidtu.be
My Website is HTTPS!
it only installs my website on home screen...
But I've seen a lot of website installing it as webapk
it also doesn't show add to home screen button, In android I have to go and click add to home screen by clicking those three dots in top right corner...
In Desktop I have no way to install the app!
you can go and see my website and please tell me how can I do it!
Is it possible to allow different START_URL ?
Say I have many blogs and I want to publish a particular blog as a PWA app. So I visit the blog detail page in chrome and click 'add to home screen'. And when I click the app icon, i should go to the blog detail page only, not to the website home page. Is it possible ? Right now 'Add to home screen' is only putting link to home page of the website.
Why has the support for django 1.11 been dropped? I was using the now deprecated django-progressive-web-app
and thought of updating it, but our entire application is built on 1.11 and not completely 2.0 compliant. So what features are here which would only work on 2.0?
It would be great if you could add a distinct (perhaps optional?) value for the short_name field.
Happy to try putting in a PR for this myself if that's helpful!
Hi there,
After seeing that #10 is closed, I wanted to install it from directly git since it has not been yet released to pypi and realized that I can't, because setup.py tries to catch RuntimeError
instead of ModuleNotFoundError
,
Lines 8 to 14 in 6ba2817
pypandoc
. I think this is a mistake since descriptions are not all that important(I think) for the actual installation of the library.
Also, I'd love to learn if you are planning a new release.
Thanks!
I'm trying to use django-pwa with the Web Share API, so I need to add a line to manifest.json:
...
"share_target":
{
"action": "/share",
"params":
{
"title": "title",
"text": "text",
"url": "url"
}
},
How do I do this?
It allows me to define a custom service worker, but not a custom manifest file.
Problem (brief): The 'service worker' section of the README includes the content of serviceworker.js, however it's out of sync with the file and is broken.
Problem (detail): The main issue I noticed was when I was trying to get the custom offline page to work. The original JS file includes '/offline/' in 2 instances (note, wrapped in forward slashes), whereas the README has '/offline' in one instance and 'offline' in the other, which doesn't work as these aren't wrapped in forward slashes. It's such a minor bug that people will likely get very confused as to why it doesn't work if they copy the content from the README into their service worker file (as I did).
Proposed fix: Very easy fix - just link to the file instead. It may be tempting to just correct these forward slashes, but based on the DRY principle, we really shouldn't be repeating a whole file of code in the README when linking to it is sufficient, along with an explanation of something like "Here's our default service worker (link to file). To make your own custom service worker, you can copy this file and tweak its contents to cache the objects relevant to your project"
Hello,
This is great! I was wondering, are there any example applications (or real ones) you can point me to so I can poke around at it?
whitenoise.storage.MissingFileError: The file 'fonts/bootstrap/glyphicons-halflings-regular.eot' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f9e6cb94828>.
The CSS file 'css/django-pwa-app.css' references a file which could not be found:
fonts/bootstrap/glyphicons-halflings-regular.eot
Please check the URL references in this CSS file, particularly any
relative paths which might be pointing to the wrong location.
I don't know if raise this exception when run without whitenoise.
To bypass this i put the font file on /font/bootstrap/glyphicons-halflings-regular.eot
.
Can i open a PR and an fix it?
And, if i can, what you think? Add a font file or add a url to font file?
Thanks!
Please tell me.
I have a VUE application inside the django template.
But if update it, it stays rigidly in the cache (once help ctrl+f5).
I think because service worker cache it.
What to specify that the desired vue file is also updated in the cache?
or problem in nginx cache?
After switching to a branch without the this module included and uninstalling it from pip, I am still getting a "Not Found: /serviceworker.js" error on "GET /serviceworker.js HTTP/1.1 404". Not sure where this is getting called from anymore or how to get past it, seems like it must have been caused by this module somehow though. Still want to use this, just having to switch back an forth before it is fully integrated.
Thanks
I followed the instructions in the readme but I am getting these errors, I am on Django 2.2
Produces the following warning:
The FetchEvent for "http://localhost:8000/" resulted in a network error response: a redirected response was used for a request whose redirect mode is not "follow".
The issue is that it's caching the redirect url /offline
the fix is to instead cache /offline/
I'll attach a PR with the fix for it.
I'm struggling to get django-pwa
to work properly. I followed the setup steps and verified that /manifest.json
and /serviceworker.js
are served.
However, I still think it's not working like a proper PWA, yet. For example, I still don't get the "add to homescreen" popup.
Also, I just noticed that I always get an error: Not Found: /css/django-pwa-app.css
- whether I use the default serviceworker.js
or a custom one.
Is the configured CSS path wrong? Or do I need to provide my own CSS? I thought this comes with django-pwa
? What about the /offline
page?
Hi,
It miss the content type when returning manifest.json
it would be great to do the same as serviceworker.js
:)
Thank you !
Hello! I have been playing around with my django app and testing it out in my staging server. I just set up an external DigitalOcean Spaces storage to serve up my static files (very similar to Amazon S3). As it turns out, this caused a new problem in my codebase which originated from django-pwa's offline.html
file. A screenshot is attached below.
My speculation is that this should not be happening since clearly the request is trying to access /css/django-pwa-app.css
whereas in reality it should not be requesting files from '/'. I think this is a typo and can be fixed easily, but if it's not and I need a better understanding of how the static file serving works, please let me know!
I do know that I can just use my own offline.html
file but posting this here in case other people face the same issue.
Best,
Ahmed
Hi, exist any tutorial for this app??
Confession: I broke django-pwa in #32 (and the test suite isn't too serious about testing ;)).
Using resolve_url
does not work at the time where urlpatterns are filled, for obvious reasons.
Hello,
what is the solution to this Uncaught (in promise) TypeError: Request failed issue??
My PWA is not working in production due to this error.
When I try logging out from a user with this installed (using default serviceworker) it doesn't seem to register the logout and just redirects to the default root page for a user at '/'. This is regardless of my settings value for LOGOUT_REDIRECT_URL or adding a login_url value to logout_then_login(request, '/login/'). The issue goes away if I unregister the serviceworker.
pwa/templatetags/pwa.py:progressive_web_app_meta(context)
filters out everything but keys starting with PWA. This breaks other context values like CSP_NONCE which is necessary when trying to set security headers and adhere to secure coding practices. The script code that registers the serviceworker.js
is admittedly tiny, but for it to execute within a CSP domain, it must have a nonce value or similar registered token.
A simple hack to fix this is to merge the CSP_NONCE value from the context into the returned dictionary:
@register.inclusion_tag('pwa.html', takes_context=True)
def progressive_web_app_meta(context):
# Pass all PWA_* settings into the template
rv = {
setting_name: getattr(app_settings, setting_name)
for setting_name in dir(app_settings)
if setting_name.startswith('PWA_')
}
rv['CSP_NONCE'] = context['CSP_NONCE']
return rv
Hello all,
The links to the icons generated my django-pwa do not show the sizes attribute as set in the settings.
It leaves it empty.
This error comes up while validating html-code:
Error: Bad value "" for attribute sizes on element link
Great "app" by the way thanks for making it.
from django.urls import url
url('', include('pwa.urls')), # You MUST use an empty string as the URL prefix
from django.urls import path, url
ImportError: cannot import name 'url' from 'django.urls'
any workaround? I tried using path, and re_path and nothing
This doesn't make much sense to me. Getting django.template.exceptions.TemplateDoesNotExist for serviceworker.js which is in my static/js folder. Not sure what would make Django even think this is a template.
Any suggestions would be appreciated. Thanks!
Hi Silvio,
First, thank you for this package and your ongoing support.
We're using Django 2.2.1 and I am getting this error:
django-pwa: ServiceWorker registration successful with scope: http://127.0.0.1:8000/ 45:52:21
Service worker event waitUntil() was passed a promise that rejected with 'TypeError: Cache got basic response with bad status 404 while trying to add request http://127.0.0.1:8000/offline/'.
I can't delete this issue so I am updating here.
Error was caused by having the django-pwa urls too low in the list of application URLS. Moving it up removed this error. Hopefully this can be of some aid to someone else.
AD
service-worker.js is in the templates directory, which would lead one to believe that they can override it. However, the file is actually loaded in directly as a plain file. Would you be open to a PR to change the behavior to use template based loading? With caching, the performance difference would be non-existent after the first request, and it would allow for some more powerful customization of the logic within that file.
For some reason, my scope entry in manifest.json ends up as a list:
scope: ["/calendar"]
although it starts up as
PWA_APP_SCOPE = '/calendar/',
(I have tried '/calendar' and '/' as well, with them all ending up as only item in a list.)
This does NOT happen with PWA_APP_START_URL, that seems to be very similar...
I have tried to look trough the django-pwa code, without success.
Hello everyone, I'm getting this error only production.
Steps to reproduce:
pip install whitenoise
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
python manage.py collectstatic
In my particular case, my staticfiles.json looks something like this:
{
...
"css/django-pwa-app.css": "css/django-pwa-app.bf6b48f24c55.css
...
}
When accessing to offline.html django can't find django-pwa-app-css
Does this support iPhone X & Xs? I’ve been trying it with both but can only get it to work on older iPhones like the iphone 7.
Does anyone have any info on this?
Could this be an Apple issue?
I have updated the package and now the is accepting include splash screen for iOS.
Originally posted by @silviolleite in #4 (comment)
Is it possible to add settings so you can still use the Debug screen in dev mode ?
I installed django-pwa
according to the instructions, adjusted the paths in serviceworker.js
to serve my icons, and checked that manifest.json
, serviceworker.js
, and offline
are served.
Still I do not get the "Add to homescreen" popup on Chrome. Any ideas why not?
I have {% load pwa %}
in my base template and want it to get installed only for logged in users so pages and assets can authenticate and cache properly. My login page does not extend the base template, but the serviceworker still seems to get installed on this page anyway, which causes the precaching to fail due to unauthenticated requests.
Any ideas for how to handle this situation properly? Why is it getting installed on a page that doesn't include the load pwa
directive? Anything else I can do to work around this?
Thanks, hoping this plugin will help with my Django pwa project!
Anyway to get around this without using bootstrap?
more details
Whitenoise.storage.MissingFileError: The file 'fonts/bootstrap/glyphicons-halflings-regular.eot' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7fb5b8567790>.
The CSS file 'css/django-pwa-app.css' references a file which could not be found:
fonts/bootstrap/glyphicons-halflings-regular.eotPlease check the URL references in this CSS file, particularly any
relative paths which might be pointing to the wrong location.
When uploading a file with the form, in the views, reuqest.FILES
is empty and request.META['CONTENT_LENGTH'] = 0
.
Package installs tests to "site-packages/tests" directory, should be moved or removed?
$ venv/bin/pip install django-pwa
$ venv/bin/pip uninstall django-pwa
Found existing installation: django-pwa 1.0.10
Uninstalling django-pwa-1.0.10:
Would remove:
.../venv/lib/python3.9/site-packages/django_pwa-1.0.10.dist-info/*
.../venv/lib/python3.9/site-packages/pwa/*
.../venv/lib/python3.9/site-packages/tests/*
Proceed (y/n)? n
Hi,
my Django PWA is giving errors and I think it is related to the fact that I am serving all my static files from AWS S3.
How do make PWA to pick static files from AWS and work properly??
I get this error "Uncaught (in promise) TypeError: Request failed"
I am getting 404 not found
after implementing django-pwa
app (Static file, offline and the png files defined in the serviceworker.js
file). I don't know if the problem is about paths or not. But there is a missing detail in the README.md
file that users needs to know. Do you have any idea?
Console log: Uncaught (in promise) TypeError: Request failed serviceworker.js:1
Network:
Request URL: http://127.0.0.1:8000/offline/
Request Method: GET
Status Code: 400 Bad Request
Remote Address: 127.0.0.1:8000
Referrer Policy: no-referrer-when-downgrade
Request URL: http://127.0.0.1:8000/static/css/django-pwa-app.css
Request Method: GET
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8000
Referrer Policy: no-referrer-when-downgrade
Request URL: http://127.0.0.1:8000/static/images/icons/icon-72x72.png
Request Method: GET
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8000
Referrer Policy: no-referrer-when-downgrade
PWA_APP_SHORTNAME & PWA_APP_NAME both default to name and not short_name distinction.
Hello,
Could you include by default the new property maskable ?
{
…
"icons": [
…
{
"src": "path/to/maskable_icon.png",
"sizes": "196x196",
"type": "image/png",
"purpose": "any maskable"
}
]
…
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.