Django’s views system provides a perfectly good way to run a website. However, it’s sometimes useful to have real-time updates to data, without the user having to navigate around or refresh a page—for example, if you’ve got a lot of fast-changing content.
The best way to handle this sort of dynamic, real-time data is with Django Channels. Channels adds asynchronous events to Django. When something changes on the server, you can notify the user that that thing changed without waiting for the user to manually check. This has the potential to make Django event-driven—to have things happen in the user’s browser in direct response to something changing. This is great if you want to show a real-time set of updates—new posts, or live chat, or changing vote totals, or activity by other users.
In this tutoruial, we’ll look at a very simple example—Django’s tutorial polls app—but altered to use Channels so that the results for polls are updated dynamically in real time as the user watches.