Django Channels

What is it? Why care? How to use it?

Django

Pre-Channels

Request goes in.

Src: Jacob Kaplan-Moss

Get Started with Channels

Response goes out.

You can't explain it...

What is it?

 

Django

Post-Channels

Request goes in.

Src: Jacob Kaplan-Moss

Yeah......

What is it?

 

Why care?

(Maybe you shouldn't)

If you don't need async, don't use it.

Async processing is hard.

Don't overcomplicate your application if you really don't need data that realtime.

Initial builds can be done without channels, and then as you determine the UX pain points you can round out the experience with this.

 

 

Why care?

All the protocols

Channels is about protocol extensibility.

 

Django supports HTTP/HTTPS.  Channels (originally called django-onair) was started explicitly to allow Django to use WebSockets. 

 

Eventually Channels was redefined so that architecture could support other protocols (MQTT, XMPP,etc) and would be future proofed against additional protocols.

 

 

To the code!

How to use it?

Classic Django

Django Channels

$ django-admin runserver
$ daphne -b 0.0.0.0 -p 80 testproject.asgi:channel_layer


$ python manage.py runworker

Running on the CLI

How to use it?

Django Channels: What, Why, and How

By Robert Roskam

Django Channels: What, Why, and How

A short walk-thru the architecture of django-channels

  • 431