Migrating from Traditional Django to djust: A Practical Guide
The Incremental Approach
You don't need to rewrite your entire Django application to use djust. You can adopt it incrementally, adding reactive features to specific pages while keeping the rest of your app unchanged.
Step 1: Install djust
pip install djust
Add to your settings:
# settings.py
INSTALLED_APPS = [
# ... your apps
"djust",
]
Step 2: Identify Candidates
Look for pages that would benefit from real-time updates:
- Forms with instant validation
- Search with live results
- Dashboards with live data
- Interactive tables with sorting/filtering
Step 3: Convert a View
Before (traditional Django):
class SearchView(TemplateView):
template_name = "search.html"
def get_context_data(self, **kwargs):
query = self.request.GET.get("q", "")
results = Product.objects.filter(name__icontains=query)
return {"query": query, "results": results}
After (djust LiveView):
from djust import LiveView, debounce
class SearchView(LiveView):
template_name = "search.html"
def mount(self, request):
self.query = ""
self.results = []
@debounce(wait=0.3)
def search(self, query):
self.query = query
self.results = list(Product.objects.filter(name__icontains=query)[:20])
Step 4: Update the Template
Replace form submissions with live events:
<!-- Before: full page reload -->
<form method="get">
<input name="q" value="{{ query }}">
</form>
<!-- After: live updates -->
<input dj-input="search" value="{{ query }}">
Coexistence
djust views work alongside traditional Django views. Your existing URLs, middleware, and authentication all work as expected. Migrate at your own pace.
Related Posts
djust 0.2.2: The Debug Panel Gets Real
djust 0.2.2 transforms the debug panel from a static inspector into a live development companion. Event filtering, replay, network inspection, VDOM patch tracing, and live state updates via WebSocket — all wired up and working out of the box.
djust 0.2.1: WebSocket Security Hardening with Three Layers of Defense
djust 0.2.1 locks down WebSocket event dispatch with an event name guard, @event_handler decorator allowlist, server-side rate limiting, and per-IP connection tracking. A security-focused release with zero new features to break.
58 Ways to Break a VDOM (and Why Ours Didn't)
We wrote 58 torture tests targeting every weak spot in djust's virtual DOM diff engine: 50-level deep trees, 500-sibling lists, keyed shuffles, duplicate keys, and rapid-fire state updates. Everything passed. Here's what we tested, what we found, and why it matters.