{# Page assets live INSIDE the content block (the dj-root): dj-navigate swaps only that region, so anything in extra_head/extra_scripts is missing when a visitor arrives by live navigation. Behaviour lives in static/js/site-pages.js. #}
DJE-021 Warning Serialization
Field serialization silently skipped
Error message
LiveView state not preserved across reconnectionsWhen a LiveView instance attribute contains a non-serializable value (e.g., a queryset, file handle, or custom object), djust's state serialization silently skips that field. On WebSocket reconnection, the skipped fields are missing from the restored state, causing subtle bugs.
serialization silent-failure
Affected versions: >=0.2.0
Solution
Recommended
Convert complex objects to serializable types
Store only JSON-serializable values (strings, numbers, lists, dicts) as LiveView instance attributes. Convert querysets to lists and custom objects to dicts in mount() or handle_event().
Before (problematic)
class UserList(LiveView):
def mount(self, request):
# QuerySet is not serializable!
self.users = User.objects.all()
self.selected = None # OK, but watch for model instances
After (fixed)
class UserList(LiveView):
def mount(self, request):
# Convert to list of dicts
self.users = list(
User.objects.values("id", "username", "email")
)
self.selected_id = None # Store ID, not object