Skip to main content

A simple wrapper of the sse python implementation for django

Project description

Django SSE wrapper is an easy way to implement Server-Sent Events in a Django application. You can find details about SSE at


Installing from PyPI:

$ pip install django-sse-wrapper


Django SSE Wrapper exposes a view called EventStreamView that implements the SSE logic. In your you will specify a pattern like:

from django.conf.urls import patterns, url

from sse_wrapper.views import EventStreamView

urlpatterns = patterns(

You can also specify a channel extension. This may be useful, for example, when you have an event stream called course_state_stream, but that needs to differ from one course to another (by course_id, for example). The url pattern would look like:

from django.conf.urls import patterns, url

from sse_wrapper.views import EventStreamView

urlpatterns = patterns(


For now, I only support two backend brokers: Memory (testing purpose only) and Redis. Soon I’ll be adding support to RabbitMQ, ZeroMQ, and others.

In your you must specify the broker and its properties:

SSE_BACKEND_CLASS = 'sse_wrapper.backends.redis_based.RedisBasedBackend'
    'host': 'localhost',
    'port': 6379,
    'db': 0,

Production Environment Notes

Because Server-Sent Events are streams of data, they require long-lived connections. You’ll want to use a server can handle large numbers of simultaneous connections. I strongly recomend you to use some gevent WSGI server.


Install Vagrant in order to run the example app and test the code.


BSD License

Note: this project is based on django-sse written by niwibe. The reason I started a new project instead of forking is that I decided to change the whole design of the code. I like the idea of omitting the broker from the app code, this way when you decide to change from one broker to another, you just have to change your

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

django-sse-wrapper-0.0.4.tar.gz (4.5 kB view hashes)

Uploaded source

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