Welcome to Chanx Documentation
Chanx: The enhanced toolkit for Django Channels
Chanx provides a robust framework for building WebSocket applications in Django with authentication, structured messaging, and testing capabilities. It builds on Django Channels to offer a more complete solution for real-time features.
Key Features
DRF-style Authentication: Use Django REST Framework authentication for WebSockets
Structured Messaging: Type-safe message handling with Pydantic validation
Group Management: Automatic channel group management for pub/sub messaging
Testing Utilities: Simplified WebSocket testing infrastructure
Playground UI: Interactive WebSocket exploration and testing tool
Getting Started
pip install chanx
# settings.py
INSTALLED_APPS = [
# ...
'chanx',
'channels',
# ...
]
Quick Example
from chanx.generic.websocket import AsyncJsonWebsocketConsumer
from chanx.messages.incoming import IncomingMessage
from chanx.messages.outgoing import PongMessage
class EchoConsumer(AsyncJsonWebsocketConsumer):
INCOMING_MESSAGE_SCHEMA = IncomingMessage
async def receive_message(self, message, **kwargs):
# Echo back with a pong
await self.send_message(PongMessage())
Contents
Getting Started
API Reference
Development