Skip to main content

Django websub subscriber

Project description

Django websub subscriber.


pip install websubsub

Add websubsub.apps.WebsubsubConfig to the list of INSTALLED_APPS in your



Create Websub callback

Create celery task handler, usually in

from celery import shared_task

def news_task(data):
    print('got news!')

Callback url should end with uuid. Register url for handler in

from websubsub.views import WssView
from .tasks import news_task, reports_task

urlpatterns = [
    path('/websubcallback/news/<uuid:id>', WssView.as_view(news_task), name='webnews')
    path('/websubcallback/reports/<uuid:id>', WssView.as_view(reports_task), name='webreports')


Set the SITE_URL setting in your to the full url of your project site, e.g. It will be used to build full callback urls.

Set WEBSUBS_REDIS_URL settings in your Redis locks are used to ensure subscription/unsubscription tasks are consistent with hub and local database.

You can create subscription on the go, or use static subscriptions.

To create subscription in the code:

from websubsub.models import Subscription
Subscription.create(topic='mytopic', urlname='webnews', hub='')

This will create Subscription object in the database and schedule celery task to subscribe with hub.

Static subscriptions

[TODO] Not sure it is the best way to handle static subscriptions.

Static subscriptions can be defined in your, they are then materialized with management command ./ websubscribe_static.

Add static subscriptions in your

    '': {
        'subscriptions': [
            # (topic, urlname) pairs
            ('mytopic', 'webnews'),

Execute ./ websubscribe_static


Not implemented


SITE_URL - ex.: Required. Will be used to build full callback urls.

WEBSUBS_REDIS_URL - ex.: redis://redishost:6379. Required. Will be used to lock atomic tasks.






Project details

Download files

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

Source Distribution

websubsub-0.3.tar.gz (9.6 kB view hashes)

Uploaded source

Built Distribution

websubsub-0.3-py3-none-any.whl (13.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page