Home Features Docs Blog Security Examples Quick Start

Migrating from Traditional Django to djust: A Practical Guide

djust Team | | 2 min read
Transformation from Django squares to djust circles

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.

Share this post

Related Posts