djust
raw JSON → 0.9.6rc1 verified Sat May 09 auth: no python
djust is a Django library for building reactive, Phoenix LiveView-style components with Rust-powered performance. It enables real-time UI updates over WebSocket without a JavaScript build step. Current version is 0.9.6rc1, with active development and a release cadence of roughly monthly minor releases.
pip install djust Common errors
error ModuleNotFoundError: No module named 'djust' ↓
cause djust is not installed or the package name is misspelled.
fix
Install with 'pip install djust' and ensure you're using the correct import path (e.g., 'from djust.views import LiveView').
error AttributeError: module 'djust' has no attribute 'LiveView' ↓
cause Imported LiveView from the wrong module. LiveView is in djust.views, not the top-level package.
fix
Use 'from djust.views import LiveView' instead of 'from djust import LiveView'.
Warnings
breaking Breaking change in v0.9.5: LiveView.mount() now requires async signature. Previously mount() was synchronous; now it must be async def mount(self, request, **kwargs). ↓
fix Change def mount(...) to async def mount(self, request, **kwargs) and use await for any async calls.
deprecated The djust.utils.emit_one_shot_class_warning function is deprecated as of v0.9.5rc2. Use the class-based warning system instead. ↓
fix Replace calls to emit_one_shot_class_warning with warnings.warn() or a custom warning class.
gotcha The dj-if boundary markers in templates (from v0.9.4) require that the if block body contains at least one element node; otherwise, no markers are emitted, which can break diffing for conditionals that render only text. ↓
fix Ensure each {% if %} block contains an HTML element (e.g., a <span>) to guarantee marker injection.
Imports
- LiveView wrong
from djust import LiveViewcorrectfrom djust.views import LiveView
Quickstart
from django.urls import path
from djust.views import LiveView
from djust.template import djust_template
class CounterView(LiveView):
template_name = "counter.html"
def mount(self, request, **kwargs):
self.context['count'] = 0
async def handle_event(self, event):
if event['type'] == 'increment':
self.context['count'] += 1
return self.render()
urlpatterns = [
path('counter/', CounterView.as_view(), name='counter'),
]
# In templates/counter.html:
# {% load djust_tags %}
# <div dj-root>
# <p>Count: {{ count }}</p>
# <button dj-on:click="increment">+</button>
# </div>