Installation
Requirements
Chanx has the following dependencies:
Python 3.10+
Django 5.0+
Django Channels 4.0+
Django REST Framework 3+
Pydantic 2.0+
Structlog 23.1+
Installing Chanx
You can install Chanx from PyPI:
pip install chanx
For installations with additional features:
# Install with camelCase conversion support
pip install chanx[camel-case]
Or install from source:
git clone https://github.com/huynguyengl99/chanx.git
cd chanx
pip install -e .
# Or with extras
pip install -e ".[camel-case]"
Basic Setup
Add necessary apps to your
INSTALLED_APPSin Django settings:
INSTALLED_APPS = [
# ...
'rest_framework',
'channels',
'chanx.playground', # Only needed for the WebSocket playground
# ...
]
Note
The chanx.playground app provides an interactive WebSocket testing interface.
It's highly recommended for development as it allows you to explore and test
your WebSocket endpoints without writing client-side code.
Set up the WebSocket playground URLs:
# urls.py
from django.urls import path, include
urlpatterns = [
# ...
path('playground/', include('chanx.playground.urls')),
# ...
]
Optional Features
Chanx offers additional features through optional dependencies:
camelCase Conversion
If you want to automatically convert message keys between snake_case (Python) and camelCase (JavaScript), you need to install the pyhumps package:
pip install chanx[camel-case]
Then enable the feature in your settings:
# settings.py
CHANX = {
'CAMELIZE': True,
# Other settings...
}
This will automatically convert snake_case fields to camelCase when sending to clients and convert camelCase back to snake_case when receiving from clients.
Verifying Installation
To verify that Chanx is correctly installed:
Start your Django development server:
python manage.py runserver
Navigate to the playground:
http://localhost:8000/playground/websocket/
You should see the WebSocket playground interface.
Next Steps
Now that you have Chanx installed, proceed to:
Configuration - Configure Chanx settings
Quick Start - Create your first WebSocket consumer
User Guide - Explore the user guide for detailed information