Home Features Philosophy Docs Blog Errors Security Examples FAQ
DJE-021 Warning Serialization

Field serialization silently skipped

Error message

LiveView state not preserved across reconnections

When 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

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