Home Features Docs Blog Security Examples FAQ

Introducing djust: Reactive Django Apps Powered by Rust

djust Team | | 6 min read
djust framework logo with Django and Rust icons

The Problem: Django Needs a Reactive Layer

Every Django developer hits the same wall. You build a clean, well-structured backend — then the client asks for a live search bar, a real-time dashboard, or a form that validates as you type. Suddenly you're wiring up React or Vue, duplicating logic across two languages, and managing a build pipeline that has nothing to do with your application.

Tools like HTMX and Django Unicorn have made progress here. But what if you could go further — server-driven state, automatic DOM diffing, WebSocket transport — with rendering performance that beats traditional templates by an order of magnitude?

That's what djust does.

What is djust?

djust is a reactive rendering framework for Django. You write views and templates in Python and standard Django template syntax. The framework compiles your templates into a Virtual DOM tree using a Rust engine, connects the browser over WebSocket, and patches only the nodes that changed — all without requiring you to write JavaScript.

The client-side runtime is ~29KB gzipped with zero build step. There's no bundler, no node_modules, no framework lock-in on the frontend.

Performance: Rust VDOM Engine

Traditional Django templates re-render the entire string for every request. djust compiles templates into a Virtual DOM tree written in Rust, enabling sub-millisecond patching.

Engine100 Items Render Time
Django Templates25.0ms
Jinja212.0ms
djust (Rust)0.8ms

The 30x improvement comes from smart diffing — djust only sends patches for the DOM nodes that actually changed, rather than re-rendering everything. On the server side, benchmarks show dashboard renders at ~37μs (27,000 renders/sec).

Standard Django Templates, No New Syntax

djust supports Django template inheritance — {% extends %}, {% include %}, {% block %} — everything you already know. Templates are compiled into a single VDOM tree for optimal performance.

Here's a complete reactive counter — the Python view and its template:

# views.py — a complete reactive view
from djust import LiveView, state

class CounterView(LiveView):
    template_name = "counter.html"
    count = state(default=0)

    def increment(self, params):
        self.count += 1

The template uses dj-click to bind the button to the server-side handler:

<!-- counter.html -->
<div data-djust-root>
  <p>Count: {{ count }}</p>
  <button dj-click="increment">+1</button>
</div>

The button click triggers a server event over WebSocket, the state updates, and the Rust VDOM engine patches only the changed text node. See more working examples on the examples page.

Automatic N+1 Query Elimination

The N+1 query problem is the most common performance killer in Django applications. djust's query optimizer analyzes your templates to detect which database fields you're accessing, then automatically injects optimal select_related and prefetch_related calls. Zero N+1 queries and faster page loads — without manual optimization.

State Management Primitives

djust provides decorators for the patterns that are hard to get right in frontend development:

  • @debounce — Delay server requests until the user stops typing, ideal for search inputs
  • @optimistic — Update the UI instantly while validating on the server, giving a zero-latency feel
  • @cache — Cache responses client-side for repeated queries
  • @client_state — Sync multiple components instantly without a server roundtrip

These handle the patterns that typically require a JavaScript state management library.

Lazy Hydration and Client-Side Navigation

For pages with many interactive sections, djust supports lazy hydration — below-fold components defer their WebSocket connections until they enter the viewport (or receive user interaction). This reduces memory usage by 20–40% per page.

TurboNav integration provides client-side navigation between pages. WebSocket connections are properly disconnected on navigation and reinitialized when returning, so LiveView components work correctly across page transitions.

Security Built In

djust includes HTML tag whitelisting to prevent XSS, automated vulnerability scanning via CodeQL, and pre-commit security hooks. The Rust core is compiled with LTO and stripped symbols in release builds.

Current Status

djust is in alpha (v0.2.0). The API is stabilizing but may change. It's already being used to build djust.org itself (dogfooding), and the core rendering pipeline is well-tested. If you're evaluating it for a new project, it's a good time to start — early feedback shapes the framework.

Key capabilities available today:

  • LiveView reactive rendering with Rust VDOM
  • 40+ UI components (Bootstrap 5 and Tailwind CSS)
  • Automatic N+1 query elimination
  • WebSocket state management with decorators
  • Lazy hydration and TurboNav client-side navigation
  • Django template inheritance (extends, include, block)
  • Form handling with real-time validation

Getting Started

Installation:

pip install djust

From there:

  • Quickstart guide — build your first reactive view in 5 minutes
  • Live examples — see working code for counters, search, forms, and dashboards
  • FAQ — common questions about architecture, deployment, and compatibility

Why This Matters

The Django ecosystem has tools for adding interactivity — HTMX for simple attribute-driven updates, Django Unicorn for component-based reactivity, Channels for raw WebSocket support. djust occupies a different point in that space: server-owned state, automatic DOM diffing, and declarative event binding — similar to what Elixir developers get with Phoenix LiveView — but built natively for Django with rendering performance that traditional template engines can't match.

If you want to build reactive Django applications without maintaining a separate frontend codebase, try djust.

djust is open source and available on GitHub. Star the repo, try it out, and file issues — early feedback is valuable.

Share this post

Related Posts