Home Features Docs Blog Examples FAQ
DJE-020 Warning Template

wrapper_template renders with empty context

Error message

Template renders but shows no data — no error raised

If a LiveView's wrapper_template references context variables that were never set in mount() or handle_event(), the template renders silently with empty values. There is no error or warning, making it hard to diagnose why the page appears blank.

silent-failure template

Affected versions: >=0.2.0

Solution

Recommended

Always initialize all template context in mount()

Explicitly set all context variables in mount() with sensible defaults. This makes it clear what the template expects and prevents silent empty renders.

Before (problematic)
class DashboardView(LiveView):
    template_name = "dashboard.html"

    def mount(self, request):
        # Forgot to set self.items!
        pass

    # Template: {% for item in items %} ... renders nothing
After (fixed)
class DashboardView(LiveView):
    template_name = "dashboard.html"
    items = []  # Explicit default

    def mount(self, request):
        self.items = Item.objects.filter(
            user=request.user
        ).values("name", "status")