Skip to main content

A webpush notifications plugable app for Django

Project description


A plugable django app to send chrome/firefox push notifications through GCM with Notification icon support.
a brief overview can be found here: [Google WebPushNotications](
This app uses latest ServiceWorkers so push notifications may not be supported in your browser, please check here: [Can I Use Web Pushnotifactions](
Notice that Web Pushnotifcations are a work in progress so all features might not be supported.
[Notification Spec](

You can install it easily from pypi by running
pip install django-simplepush

After installing the package, add ``simplepush`` in in your
``INSTALLED_APPS`` settings


If you would like to send notification to Google Chrome Users, you need
to add a ``SIMPLEPUSH_SETTINGS`` entry with the **Google Cloud Messanging
ID and Key** Like following:

"GCM_ID": "Your GCM ID",

**Replace ``"Your GCM ID"`` and ``"Your GCM KEY"`` with your Google
Cloud Messanging ID and Key**
To know how to obtain GCM ID and Key please see this [Documentation from Google Developers]( and the [MDN Documentation](

Then include ``simplepush`` in the ````
urlpatterns =

url(r'^simplepush/', include('simplepush.urls'))

Then run Migration by **``python migrate``**


###Adding Simplepush in Django Template

So in html template, you need to load ``simplepush_tags`` custom template tag by following:
If you are using built in templating engine, add ``{% load simplepush_tags %}`` in the template.Remember to load static files first with ``{% load static %}``. The service worker wont register if you did not put ``{% simplepush_html %}`` tag inside <head></head> Tags. If you are using jinja or other templating engine, you can manually add the html header and button and other information such as:

<script id="simplepush-js" type="text/javascript" src="/static/simplepush/simplepush.js"></script>
<script id="service-worker-js" type="text/javascript" src="/static/simplepush/simplepush_serviceworker.js"></script>
<link rel="manifest" href="/simplepush/manifest">

Next, inside the ``<head></head>`` tag add ``{% simplepush_html %}``. Like following
{% simplepush_html %}

Next, inside the ``<body></body>`` tag, insert ``{% simplepush_html_button %}``
where you would like to see the **Subscribe to Push Messaging** Button.
Like following
<p> Hello World! </p>
{% simplepush_html_button %}

**Note:** The Push Notification Button will show only if the user is logged in.
Or for jinja templates:

<button id="simplepush-subscribe-button" data-url="/simplepush/save_information">Subscribe to Push Messaging</button>

###Sending Web Push Notification
A Web Push generally have a header and body. According to the W3C Specification, the data should be encrypted in transmission. the data is addressed as payload generally. Also a TTL header should be included indicating how much time the web push server store the data if the user is not online.

You can send push notification as:

from simplepush import send_user_notification
payload = {"head":"Hello World", "body":"Testing Push Notification", "icon":"", "link":""}
send_user_notification(user=user, payload=payload, ttl=1000)

The user in this is subscribed user which will get notification to all of his subscribed browser, a user can have multiple subscriptions through various browsers or devices.
The link key in payload specifies the url which can be opened when clicking on Notification


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-simplepush-0.11.tar.gz (10.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page