Skip to main content

Channels-Redux

Channels-Redux is a package that notifies subscribers about changes in the database

It should be paired with the npm package of the same name. The pypi package django-react-views is also useful for hydrating initial state

Exposed Modules

NotifyConsumer

This is an AsyncWebsocketConsumer that allows clients to subscribe to different models and objects and sends frames when subscribed objects are updated, created or deleted. Unless you plan on extending it's functionality you don't need to do anything with this.

NotifyRouter

NotifyRouter is a channels.routing.URLRouter that defines a default URL that routes connections to NotifyConsumer

NotifierMixin

Extending this mixin marks a model as being a 'Notifier' this means that it will send frames to subscribed clients when changes happen on the server side.

This also defines a property that returns the name of the api url for the model. By default it assumes the namespace of your api is 'api' this can be overridden by defining API_APP_NAMESPACE in your settings.

HyperlinkedModelSerializer

A drop-in replacement for DRF's HyperlinkedModelSerializer that fixes some issues with URL fields and relationships in a namespaced api

RestRouter

A drop-in replacement for DRF's DefaultRouter that should be used to assign the expected default base names for your api urls.

Quick Start

  1. Add to installed apps

    INSTALLED_APPS = [
       ...
       'channels_redux',
    ]
    
  2. Models that you want clients to receive notifications about should extend the NotifierMixin

  3. Setup your models with Django Rest Framework with the following exceptions:

    1. Instead of the DRF's HyperlinkedModelSerializer you should use channels_redux.rest.HyperlinkedModelSerializer. At minimum your serializers should include the url and the pk fields.
    2. User RestRouter instead of DefaultRouter for your api routes
      router = RestRouter()
      router.register(r'appname/modelname', viewsets.ModelNameViewSet)
      
  4. Setup django-channels. Follow their docs for this with the following exceptions:

    1. In routing.py use the NotifyRouter
      application = ProtocolTypeRouter({
          "websocket": AuthMiddlewareStack(NotifyRouter()),
      })
      
    2. channels-redux requires channel layers, so be sure to set those up.
  5. Use django-react-views to provide the initial data to your frontend

  6. On the frontend use channels-redux js to setup your redux state and WebsocketHandler before rendering any react components

    // In the root component that your page loads.
    import {WebSocketHandler, store} from 'channels-redux';
    const webSocketHandler = new WebSocketHandler(store);
    webSocketHandler.subscribeAll();
    

Metadata

Release files for channels-redux 1.8.0

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

Source distribution (sdist)

Source distribution for channels-redux 1.8.0
File Size Uploaded Provenance Actions
channels-redux-1.8.0.tar.gz 9.0 kB Without provenance Details for channels-redux-1.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for channels-redux 1.8.0
File Interpreter ABI Platform Actions
channels_redux-1.8.0-py3-none-any.whl Python 3 none any Details for channels_redux-1.8.0-py3-none-any.whl

Total release size: 20.0 kB

Release files / channels-redux-1.8.0.tar.gz

Download URL channels-redux-1.8.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
94d44d7f2175b4f10473843acdcb078e4be14c02dad11184e8284352aa87cc64
BLAKE2b-256 checksum
How to use checksums
cb3a0d5c5c0ae855bf90ae5c71d024e43af44ec47fc0e88538d693725d3f0716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

Release files / channels_redux-1.8.0-py3-none-any.whl

Download URL channels_redux-1.8.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97c365d871bb31ecbd012cd3ebe5aff4c71a4b7a7d70e4c7fb104f8593db6a92
BLAKE2b-256 checksum
How to use checksums
a7fd59a2d194012c38074a6db578dc5ffc9cc1034cece3903e84c7d07c42fd48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

Security for channels-redux 1.8.0

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