Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Django LiveView: A Django starter template for building real-time SPAs using HTML over WebSockets without APIs or JavaScript logic.
Django LiveView is a Django starter template that implements the HTML over WebSockets pattern, enabling real-time single-page applications without a JSON API or JavaScript-rendered frontend. It takes Django views and templates as input and produces instant, socket-delivered HTML updates in the browser, running on Django Channels and Stimulus. The template includes a full cat-management demo app covering CRUD, login, real-time broadcasts, and SSR pages for SEO, plus a live demo at django-liveview-demo.andros.dev.
Django LiveView is a Django starter template that builds real-time single-page applications by keeping all rendering and business logic in Python and using WebSockets to deliver HTML fragments to the browser. It was created by Andros Fenollosa and is provided as a runnable reference implementation with a live demo. Instead of building an API and a JavaScript frontend, the template opens a WebSocket channel via Django Channels; JavaScript only captures events and sends action names, while Django renders HTML snippets and sends them back to be inserted into the page.
The architecture routes actions through Stimulus controllers, a WebSocket client, and Django Channels consumers. When a user clicks, Stimulus sends an action string such as "about_us->update_random_number_html" over a WebSocket. The consumer in consumers.py looks up the matching function in the actions directory, which calls render_to_string() on a template and sends the resulting HTML plus a target selector via send_html(). The frontend inserts the HTML into that selector, and for page-level changes the URL is updated as well. To add a new page, you define a route, a Django view, an action file providing get_context() and send_page(), a template, and a Stimulus controller registered in main.js.
The repository is a public GitHub project with a live demo; it is provided as a starter template. The author sells a book, "Building SPAs with Django and HTML Over the Wire", which walks through the underlying concepts, but the template itself is open.
No. It uses Stimulus only as a thin event-handling layer to capture clicks and send action names over WebSockets. All business logic and HTML rendering happen in Django/Python. Substantial JavaScript development is unnecessary.
Docker and Make are required. The setup instructs you to copy envExample to .env, run docker compose up, then make run.fake to load fake data. The app runs at http://feline-web.localhost/ with Django admin at /admin/ (admin/admin for the demo).
The roadmap lists publishing a package and a website as incomplete, so it is best treated as a reference implementation or starting point rather than a maintained product. For production, you would need to handle deployment, scaling WebSockets, and packaging yourself.
