Skip to main content

Django REST Framework Reactive

Build Status Documentation Status Version on PyPI Supported Python versions Number of downloads from PyPI Code style: black

This package enables regular Django REST Framework views to become reactive, that is so that client-side applications may get notified of changes to the underlying data as soon as they happen, without the need to poll the API again. While the initial request is done as a regular HTTP request, all the update notifications come through WebSockets.

Install

Prerequisites

The reactive extensions for Django REST Framework require the use of Django Channels for push notifications via WebSockets.

From PyPI

pip install djangorestframework-reactive

From source

pip install https://github.com/genialis/django-rest-framework-reactive/archive/<git-tree-ish>.tar.gz

where <git-tree-ish> can represent any commit SHA, branch name, tag name, etc. in DRF Reactive’s GitHub repository. For example, to install the latest version from the master branch, use:

pip install https://github.com/genialis/django-rest-framework-reactive/archive/master.tar.gz

Configure

First, add rest_framework_reactive to INSTALLED_APPS.

Configure your Django Channels routing.py to include the required paths:

from django.urls import path

from channels.routing import ChannelNameRouter, ProtocolTypeRouter, URLRouter

from rest_framework_reactive.consumers import ClientConsumer, MainConsumer, WorkerConsumer
from rest_framework_reactive.protocol import CHANNEL_MAIN, CHANNEL_WORKER

application = ProtocolTypeRouter({
    # Client-facing consumers.
    'websocket': URLRouter([
        # To change the prefix, you can import ClientConsumer in your custom
        # Channels routing definitions instead of using these defaults.
        path('ws/<slug:subscriber_id>', ClientConsumer),
    ]),

    # Background worker consumers.
    'channel': ChannelNameRouter({
        CHANNEL_MAIN: MainConsumer,
        CHANNEL_WORKER: WorkerConsumer,
    })
})

Also, urls.py need to be updated to include some additional paths:

urlpatterns = [
  # ...
  url(r'^api/queryobserver/', include('rest_framework_reactive.api_urls')),
  # ...
]

Run

In addition to running a Django application server instance, you need to also run a separate observer worker process (or multiple of them). You may start it by running:

python manage.py runworker rest_framework_reactive.main rest_framework_reactive.worker

Metadata

Release files for djangorestframework-reactive 7.0.2

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

Source distribution (sdist)

Source distribution for djangorestframework-reactive 7.0.2
File Size Uploaded Provenance Actions
djangorestframework-reactive-7.0.2.tar.gz 35.5 kB Without provenance Details for djangorestframework-reactive-7.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for djangorestframework-reactive 7.0.2
File Interpreter ABI Platform Actions
djangorestframework_reactive-7.0.2-py3-none-any.whl Python 3 none any Details for djangorestframework_reactive-7.0.2-py3-none-any.whl

Total release size: 62.2 kB

Release files / djangorestframework-reactive-7.0.2.tar.gz

Download URL djangorestframework-reactive-7.0.2.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3ad460157b85403b800053e81bc33051ae85449970b98b9de28c315cdf9bfc8a
BLAKE2b-256 checksum
How to use checksums
4ec1ed4f26fa4d7d0f1ca949befbd11374f6802c573c1740e7795b23e3fadfce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / djangorestframework_reactive-7.0.2-py3-none-any.whl

Download URL djangorestframework_reactive-7.0.2-py3-none-any.whl
Size 26.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3de8f2f1bfb3ba4f90d2caca55e7e211c76f48504a40df17aeba541537444ef1
BLAKE2b-256 checksum
How to use checksums
75f4f742f060f60fad138169979b249df2efaf69c1e7cc84db3ba88583bf4a5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Security for djangorestframework-reactive 7.0.2

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.

Release history Release notifications | RSS feed

This release

7.0.2 This release

2 release files No provenance

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