Real-time notifications with Django-channels, HTMX and Server Sent Events

When using HTMX with Django, you may have come across the problem of updating HTML components in real-time based on changes that happen to the underlying data in the database. The simplest way to make real-time updates to html elements is for the client to regularly poll the backend for updates. HTMX makes this easy with polling. However, there are two issues with this: It’s not really “real-time”. You are polling the backend at a regular interval, but the data could have changed at any time in the interval.