A Django application to deliver user notifications made with django-snitch using WebSockets.
Quick start
This applications works using django-channels, so, you need to integrate this with your project before to integrate django-websocket-notifications. So, to make the quick start as quick and simple as possible, we’ve made the following assumptions:
You already have integrated django-channels
You are using a channel layer, like Redis
You have a routing.py file
Your project uses DRF to deliver a RESTful API
1 Install using pip:
pip install django-websocket-notifications
2 Add “websocket_notifications” to your INSTALLED_APPS settings like this:
INSTALLED_APPS += ('websocket_notifications',)
3 Add the routing patterns to your routing.py file:
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from websocket_notifications.routing import websocket_urlpatterns
application = ProtocolTypeRouter(
{"websocket": AuthMiddlewareStack(URLRouter(websocket_urlpatterns)),}
)
4 (Optional) In order to test the integration, you can add the following view to your urls.py file to be able to access to a testing view:
urlpatterns += [
path(
"websocket-notifications/",
include(
"websocket_notifications.urls",
namespace="websocket_notifications",
),
),
]
Now, you can access to /websocket-notifications/listener/ to check the integration.
5 Add the ViewSet to the DRF router:
from websocket_notifications.api.rest_framework import NotificationGroupViewSet
router = routers.DefaultRouter()
router.register("websocket-notifications/groups", viewset=NotificationGroupViewSet)
6 Integrate with django-snitch:
from websocket_notifications.snitch.backends import WebSocketNotificationBackend
@snitch.register(EVENT)
class MyEventHandler(snitch.EventHandler):
ephemeral = True
notification_backends = [WebSocketNotificationBackend]
Metadata
Release files for django-websocket-notifications 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_websocket_notifications-1.3.1.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_websocket_notifications-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.2 kB
Release files / django_websocket_notifications-1.3.1.tar.gz
| Download URL | django_websocket_notifications-1.3.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84378cdcaf7b2a4a2558934c88de03d6c52e10ce39d79b4d71e0d529216c94f7
|
|
BLAKE2b-256 checksum How to use checksums |
11abb88068a8b454b5477016e75459f764632e8023f8c3a89a119c738cc8f9d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
|
Release files / django_websocket_notifications-1.3.1-py3-none-any.whl
| Download URL | django_websocket_notifications-1.3.1-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fd0d042111432a26716bf65d0ccf6865c40a93abd0fdf09b24aa7fe30827bb3
|
|
BLAKE2b-256 checksum How to use checksums |
62c153408576a5f4e21d4d5051a63f6efeba072f7b895c927b0e7bacd67747d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
|