Django Channels Example
This is an example app demonstrating how to use (and deploy) Django Channels. It's a simple real-time chat app β like a very, very light-weight Slack. There are a bunch of rooms, and everyone in the same room can chat, in real-time, with each other (using WebSockets).
For a walkthrough of what's going on here, see my article over on the Heroku blog.
You can visit my deployment of the example online, or deploy your own copy to Heroku with this button (which requires a free Heroku account):
Running locally
To run this app locally, you'll need Python, Postgres, and Redis. (On my Mac, I installed Postgres.app and Redis from Homebrew (brew install redis
).)
Then, to run:
- Install requirements:
pip install -r requirements.txt
(you almost certainly want to do this in a virtualenv). - Migrate:
DATABASE_URL=postgres:///... python manage.py migrate
- If you use heroku local, or foreman/forego, edit
.env
to addDATABASE_URL
andREDIS_URL
, then startheroku local
/foreman
/forego
. - Or, to run locally with
runserver
, setDATABASE_URL
andREDIS_URL
in your environ, then runpython manage.py runserver
. - Or, to run locally with multiple proceses by setting the environ, then running the two commands (
daphne
andrunworker
) as shown in theProcfile
.
Running with Docker
Tomas Tomecek put together a Dockerized version of this app.