Skip to main content

django_infopush

django_infopush is a Django reusable app, that allows to gather push subscriptions and send web push notifications to browsers.

It is a full featured reusable app which includes:

  • frontend & backend code which gathers push subscriptions and saves them to DB,

  • service worker to show notifications, manage clicks and basic notification statistics,

  • django admin interface where you create new push tasks (title, text, icon, url, image, time to send) and view stats for the old ones,

  • django management command to perform your tasks (send notifications to subscribers).

https://raw.githubusercontent.com/kilgoretrout1985/django_infopush/master/docs/img/push_admin_list_thumb.png

This app covers 99% webpush needs for content web-sites than you just want to send an announcement of a new blog post for example. Just make a new push task in the admin and job is done.

https://raw.githubusercontent.com/kilgoretrout1985/django_infopush/master/docs/img/push_admin_add_thumb.png

Known limitations:

  • You better have access to CRON on your server, because push tasks are send using python manage.py pushsend management command. And running it manually every time sounds like a bad idea. Although for testing purposes manual calls will do well.

Quick start

  1. pip install django-infopush

  2. Add “django.contrib.humanize” (if not in INSTALLED_APPS already) and “commonstuff”, “push” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        # ...
        'django.contrib.humanize',
        'commonstuff',
        'push',
    ]
  3. Enable sites framework in Django, see official docs.

  4. Configure django_infopush in your project settings.py file. At least your DJANGO_INFOPUSH_VAPID_PUBLIC_KEY and DJANGO_INFOPUSH_VAPID_PRIVATE_KEY (you can simply generate them here).

    You also have to set DJANGO_INFOPUSH_VAPID_ADMIN_EMAIL with your site admin or support address, so that push-server administration can reach you if something goes wrong.

    E.g.:

    DJANGO_INFOPUSH_VAPID_PUBLIC_KEY = 'AHf42JhrMtFOXAG2OYTmEoBvKNcEsxmYF5pqvYd4InFEEU0x41HzymPQRtcvJZp9iNpDQK4GuTGMWAgn0E8G8IZ'
    DJANGO_INFOPUSH_VAPID_PRIVATE_KEY = 'CcmbGJ9wce7596DoObRzyPHNktPRo5CSCdericz7Pf7'
    DJANGO_INFOPUSH_VAPID_ADMIN_EMAIL = 'admin@mysite.com'

    See docs/SETTINGS.rst for more.

  5. If project uses MySQL, make sure it’s version is 5.7.7 or greater and add the following line to project’s settings.py:

    SILENCED_SYSTEM_CHECKS = ['mysql.E001']

    See docs/MYSQL.rst for details.

  6. Run python manage.py migrate to create push models.

  7. Include URLconf in your project urls.py like this:

    from django.urls import re_path, include
    from django.conf import settings
    from django.views.generic import TemplateView
    from django.views.decorators.cache import cache_page
    
    urlpatterns = [
        # ...
        re_path(r'^push/', include('push.urls')),
        re_path(r'^service-worker.js$', cache_page(1 if settings.DEBUG else 86400)(TemplateView.as_view(
            template_name="push/service-worker.js",
            content_type='application/javascript; charset='+settings.DEFAULT_CHARSET,
        )), name='service-worker.js'),
    ]
  8. Add {% include ‘push/_head_include.html’ %} into head-section of your django-project’s html template(s). Do not include it on the pages where you don’t want to see push-subscribe browser window. Visit your website to become first subscriber (currently Chrome and FF support webpush, not Safari).

  9. Visit http://127.0.0.1:8000/admin/push/ to create first push task.

  10. CRON setup for python manage.py pushsend management command (every 5-10 minutes). You can also run this command manually for testing purposes.

  11. (OPTIONAL) Run python manage.py test push for basic check of the app.

Metadata

Release files for django-infopush 1.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-infopush 1.8.1
File Size Uploaded Provenance Actions
django_infopush-1.8.1.tar.gz 482.2 kB Without provenance Details for django_infopush-1.8.1.tar.gz

Release files / django_infopush-1.8.1.tar.gz

Download URL django_infopush-1.8.1.tar.gz
Size 482.2 kB
Tags Source
SHA-256 checksum
How to use checksums
716fc2be9dc872091c2f363035bf9201132929e01a1841e44b4e902945793fb1
BLAKE2b-256 checksum
How to use checksums
37b0f53820fa8815e800b31aafe38103ce8faf272b6e25367586a755bd6ac2a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Security for django-infopush 1.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page