Skip to main content

django-realtime-chat

Plugin Django de chat temps réel via WebSocket (Django Channels + JWT).

Installation

pip install django-realtime-chat

Configuration rapide

1. settings.py

INSTALLED_APPS = [
    ...
    "channels",
    "rest_framework",
    "django_realtime_chat",
]

# Django Channels
ASGI_APPLICATION = "monprojet.asgi.application"

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {"hosts": [("127.0.0.1", 6379)]},
    }
}

2. urls.py du projet

from django.urls import path, include

urlpatterns = [
    ...
    path("chat/", include("django_realtime_chat.urls")),
]

3. asgi.py du projet

import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from django_realtime_chat.routing import websocket_urlpatterns

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "monprojet.settings")

application = ProtocolTypeRouter({
    "http": get_asgi_application(),
    "websocket": AuthMiddlewareStack(
        URLRouter(websocket_urlpatterns)
    ),
})

Authentification JWT : passez ?token=<access_token> dans l'URL WebSocket pour utiliser le middleware JWT fourni à la place de AuthMiddlewareStack.

4. Migrations

python manage.py migrate

URLs disponibles

URL Nom Description
GET /chat/ django_realtime_chat:chat_home Interface principale
GET /chat/start/<user_id>/ django_realtime_chat:start_conversation Démarre une conversation
GET /chat/history/<conv_id>/ django_realtime_chat:message_history Historique JSON
POST /chat/upload/ django_realtime_chat:file_upload Upload de fichier
GET /chat/users/ django_realtime_chat:user_list Liste des utilisateurs JSON

WebSocket

ws://<host>/ws/chat/

Payload envoyé par le client :

{ "message": "Bonjour !", "receiver_id": 42 }

Payload reçu :

{
  "message": "Bonjour !",
  "sender_id": 1,
  "sender_username": "alice",
  "conversation_id": 7,
  "message_id": 123,
  "created_at": "2025-04-06T10:30:00.000Z"
}

Metadata

Release files for django-realtime-chat 1.4.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 django-realtime-chat 1.4.0
File Size Uploaded Provenance Actions
django_realtime_chat-1.4.0.tar.gz 47.4 kB Without provenance Details for django_realtime_chat-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-realtime-chat 1.4.0
File Interpreter ABI Platform Actions
django_realtime_chat-1.4.0-py3-none-any.whl Python 3 none any Details for django_realtime_chat-1.4.0-py3-none-any.whl

Total release size: 96.8 kB

Release files / django_realtime_chat-1.4.0.tar.gz

Download URL django_realtime_chat-1.4.0.tar.gz
Size 47.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ae49cb8b481b31a83c4d5b9ec3040dda42f1652d7f2962d0ef9b0eb6fdade2b1
BLAKE2b-256 checksum
How to use checksums
ed2609241cf2f27696566cff4ca9976b3e2a60eb0ff9eee0a32ef5fad3cf5ff2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / django_realtime_chat-1.4.0-py3-none-any.whl

Download URL django_realtime_chat-1.4.0-py3-none-any.whl
Size 49.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f62b0c44cd22bc7778dd2e2f288aaa846e7c8f73720fed35d577d21559e7836
BLAKE2b-256 checksum
How to use checksums
2896e0f095cd91f1629eb01e979108fb75536c83a295fdb02bdc3a934494adb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for django-realtime-chat 1.4.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