Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Real-Time Django with Channels

Real-Time Django with Channels

PyCon Dhaka 2016 talks on Django Channels.

Avatar for Md Arifin Ibne Matin

Md Arifin Ibne Matin

October 14, 2016

More Decks by Md Arifin Ibne Matin

Other Decks in Programming

Transcript

  1. Hi, I’m Md Arifin Ibne Matin • Software Engineer at

    • Foodie & Hobbyist Cook • Problem Solver, Programmer.
  2. Django was getting ‘Old’ ! • We want rich web

    applications with real-time interactions. • Django primarily is a request/response based framework. • 3rd party solutions is needed for WebSockets.
  3. Vanilla Django • Take a Request ..
 .. Return a

    Response. • Incompatible with WebSockets Source : https://blog.heroku.com/in_deep_with_django_channels_the_future_of_real_time_apps_in_django
  4. Project: Channels … is a project to make Django able

    to handle more than just plain HTTP requests, including WebSockets and HTTP2, as well as the ability to run code after a response has been sent … Andrew Godwin • Django Core Developer • Creator of ‘South’ Adopted as an official Django project
  5. Concepts • Interface server : handle different protocols. • Channel

    Layer: Deliver to Consumers. • Consumer: Consumes a message and take actions. Source : https://blog.heroku.com/in_deep_with_django_channels_the_future_of_real_time_apps_in_django
  6. • An Ordered, first-in-first-out, at-most-once queue with expiry and delivery

    to only one listening consumer. • Identified by a unique unicode name. • In-Memory / IPC/ Redis. • Standard channel names:
 http.request
 websocket.connect
 websocket.receive
 websocket.disconnect • Clients have unique response channel (reply_channel):
 !http.response.ja24Rdj
 !websocket.send.EdsU230f • Group: Named set of channels to broadcast What is a Channel?
  7. A consumer receives a message and sends zero or more

    messages. What is a Consumer? A view receives a request and sends single response. Request Response View Message Consumer Message Receive from channels, and send to them/groups. WebSocket/HTTP messages come with a reply_channel
  8. Commentary (https://github.com/arifin4web/commentary) A simple application to demonstrate WebSocket Broadcasting using

    Django Channels. Anyone can add feeds/comments to any events and all the connected users will get live updates. ? localhost tunnel url here ? Demo
  9. • PyCon 2016 Talk by Andrew Godwin • Abu Ashraf

    Masnun’s Blog post • Another great post by Jacob Kaplan-Moss. • And off course the Official Documentation. This Slide and other links will be published 
 on my website :
 
 http://arifin4web.github.io/talks/ Further