Having played extensively with Django Channels 1 a few years ago, I thought Django Channels 2 would be easy. That turned out not to be the case. Critical things like handling authenticated users and linking messages to layers have holes in the official documentation.
A lot of people are afraid to admit that they don't understand something technical within our chosen field, including me. We blame on our shortcomings rather than the possibility that the documentation may need improvement. This became apparent as days of effort went by with disappointing results. What should have been trivial tasks in Channels were things I discovered to be very challenging.
This explains the amazing frequency of requests I get to build tutorials for channels 2. This is why there are so many Django projects with Firebase, Pusher, and other async WebSocket-like toolings stapled on: Channels does not make this easy.
Fortunately, Mark Dobossy came to my aid, supplying some sample code he had hacked together. I got pub/sub working with Channels 2.
Note that this example is not for authenticated users, rather it just shows how with a model update you can inform ALL users that a model has been updated. Controlling who receives this information will come in a future video.
I like to fix things, rather than merely complain. So in the future I will be submitting pull requests back to Channels to address the issues I raised here. I will also document these things in long form here on my youtube channel, as well as in my blog, and books.
---
My name is Daniel Feldroy, sometimes known as "Daniel Roy Greenfeld" or "pydanny". I've been a professional software developer for over 20 years and am a co-author of Two Scoops of Django and Django Crash Course.
Take my video courses at https://www.feldroy.com/pages/courses
Buy my books at https://www.feldroy.com
Support me on Patreon: / feldroy
Sponsor me on GitHub: https://github.com/sponsors/pydanny
All my videos are originally streamed, including this one, at / danielfeldroy