Skip to content
djust/docs
Appearance
Mode
djust.org →
Browse documentation

API Reference · 33 entries · config

Config reference

Two ways to configure djust: per-view class attributes (set on a LiveView subclass) control that view’s behaviour, while DJUST_CONFIG keys in settings.py set project-wide defaults for security, serialization, transport, and developer tooling.

LiveView attributes

19 entries

Attributes you set directly on a LiveView subclass to control that view: which template it renders, authentication and permissions, memory behavior (temporary_assigns, static_assigns), stickiness across navigation, and opt-in features like state snapshots and streaming render.

template_name Path to the Django template for this view (relative to the template dirs).
Type
str
Default
None

Path to the Django template for this view (relative to the template dirs). Either template_name or template is required.

Python Class attribute
class ProfileView(LiveView):
    template_name = 'profile.html'
template An inline template string, rendered directly without a file lookup.
Type
str
Default
None

An inline template string, rendered directly without a file lookup. Handy for tiny views or tests; use template_name otherwise.

Python Class attribute
class SimpleView(LiveView):
    template = '<div dj-root>{{ count }}</div>'
tick_interval When set (milliseconds), handle_tick() is called periodically on the server — useful for clocks or status polling.
Type
int
Default
None

When set (milliseconds), handle_tick() is called periodically on the server — useful for clocks or status polling. None disables ticking.

Python Class attribute
class ClockView(LiveView):
    tick_interval = 1000

    def handle_tick(self):
        self.now = timezone.now()
temporary_assigns Maps assign name -> default value; the assign is reset after each render.
Type
dict
Default
{}

Maps assign name -> default value; the assign is reset after each render. A memory optimisation for large collections (chat messages, feeds) you don't want held in server state.

Python Class attribute
class ChatView(LiveView):
    temporary_assigns = {'messages': []}
static_assigns Names of assigns sent to the client only on the first render; the Rust engine retains them across patches.
Type
list[str]
Default
[]

Names of assigns sent to the client only on the first render; the Rust engine retains them across patches. Use for large, unchanging context to keep the state channel small.

Python Class attribute
class DocsView(LiveView):
    static_assigns = ['catalog']
login_required When True, unauthenticated users are redirected to login_url before mount().
Type
bool
Default
None

When True, unauthenticated users are redirected to login_url before mount(). Use permission_required for role checks.

Python Class attribute
class Dashboard(LiveView):
    login_required = True
    login_url = '/login/'
permission_required Django permission string(s) checked after authentication; a single string or a list.
Type
str | list[str]
Default
None

Django permission string(s) checked after authentication; a single string or a list. Raises PermissionDenied if not met.

Python Class attribute
class AdminView(LiveView):
    permission_required = ['app.view_data', 'app.change_data']
login_url Where to send unauthenticated users when login_required=True.
Type
str
Default
None

Where to send unauthenticated users when login_required=True. Overrides settings.LOGIN_URL.

Python Class attribute
class PrivateView(LiveView):
    login_required = True
    login_url = '/accounts/login/'
on_mount Hook functions run before mount() on every mount/reconnect, in MRO order.
Type
list[Callable]
Default
[]

Hook functions run before mount() on every mount/reconnect, in MRO order. Each returns None to continue or a URL to redirect. See the @on_mount decorator.

Python Class attribute
class ProfileView(LiveView):
    on_mount = [require_verified_email]
api_name Stable slug for HTTP API exposure: handlers marked @event_handler(expose_api=True) are served at /djust/api/<api_name>/.
Type
str
Default
None

Stable slug for HTTP API exposure: handlers marked @event_handler(expose_api=True) are served at /djust/api/<api_name>/. If None, derived from the module path (not stable across renames).

Python Class attribute
class ExportView(LiveView):
    api_name = 'data_export'
api_auth_classes Auth classes tried in order for the HTTP API; the first returning a user wins.
Type
list
Default
None

Auth classes tried in order for the HTTP API; the first returning a user wins. Defaults to [SessionAuth] when None. CSRF is enforced unless the winning class is csrf_exempt.

Python Class attribute
class APIView(LiveView):
    api_name = 'endpoint'
    api_auth_classes = [TokenAuth(), SessionAuth()]
sticky Preserve this view's instance and DOM across live_redirect navigation.
Type
bool
Default
False

When True and embedded via {% live_render sticky=True %}, the instance, DOM, form values, scroll/focus and background tasks survive live_redirect navigation — provided the destination layout has a matching dj-sticky-slot.

Python Class attribute
class SidebarView(LiveView):
    sticky = True
    sticky_id = 'main_sidebar'
sticky_id Required when sticky=True.
Type
str
Default
None

Required when sticky=True. Must match the dj-sticky-slot name in the destination template to preserve state across navigation.

Python Class attribute
class ChatSidebar(LiveView):
    sticky = True
    sticky_id = 'chat_sidebar'
use_actors Routes event handlers through the Tokio actor system instead of the thread pool (Phase 5+, experimental).
Type
bool
Default
False

Routes event handlers through the Tokio actor system instead of the thread pool (Phase 5+, experimental). Set True only for features that need actor isolation.

Python Class attribute
class CounterView(LiveView):
    use_actors = True
enable_state_snapshot Opt in to back-navigation state restoration via the Service Worker.
Type
bool
Default
False

Opt in to Service-Worker state restoration on back-navigation: the client posts a JSON state snapshot on popstate and the server restores public attributes before mount(). Override _should_restore_snapshot() to reject stale snapshots.

Python Class attribute
class FilteredList(LiveView):
    enable_state_snapshot = True
streaming_render Return a chunked StreamingHttpResponse from HTTP GET for faster first paint.
Type
bool
Default
False

When True, an HTTP GET returns a StreamingHttpResponse flushed in chunks (shell-open, content, shell-close) so the browser can load CSS/JS while the server computes content. Requires ASGI.

Python Class attribute
class LargeDetail(LiveView):
    streaming_render = True
time_travel_enabled Dev-only: records a per-instance ring buffer of event snapshots so the debug panel's Time Travel tab can scrub history.
Type
bool
Default
False

Dev-only: records a per-instance ring buffer of event snapshots so the debug panel's Time Travel tab can scrub history. Gated on DEBUG=True; no-ops in production.

Python Class attribute
class DebugView(LiveView):
    time_travel_enabled = True
abstract Marks an abstract base LiveView so system checks (e.g.
Type
bool
Default
False

Marks an abstract base LiveView so system checks (e.g. requiring template_name) skip it. Not inherited — subclasses must redeclare it. Mirrors Django's Meta.abstract.

Python Class attribute
class BaseFormView(LiveView):
    abstract = True
allowed_model_fields Restricts which attributes dj-model may bind.
Type
list[str]
Default
None

Restricts which attributes dj-model may bind. None allows all non-forbidden fields; a list restricts to exactly those. Forbidden fields (template_name, request…) are always blocked.

Python Class attribute
class FormView(LiveView):
    allowed_model_fields = ['name', 'email', 'message']

DJUST_CONFIG settings

14 entries

Project-wide defaults set in settings.py under DJUST_CONFIG: the CSS framework, event-handler security mode, WebSocket message limits and rate limiting, serialization behavior, and developer tooling such as hot reload and time-travel debugging. These apply to every view unless a class attribute overrides them.

css_framework Which CSS framework the form helpers and components target: 'bootstrap5', 'bootstrap4', 'tailwind', or None.
Type
str
Default
'bootstrap5'

Which CSS framework the form helpers and components target: 'bootstrap5', 'bootstrap4', 'tailwind', or None. Drives the default field/error/button classes.

Python settings.py
DJUST_CONFIG = {
    'css_framework': 'tailwind',
}
event_security How strictly event handlers must be marked (open / warn / strict).
Type
str
Default
'strict'

How strictly event handlers must be marked: 'open' (no checks), 'warn' (allow unmarked, log), 'strict' (only @event_handler methods are callable). Use 'strict' in production.

Python settings.py
DJUST_CONFIG = {
    'event_security': 'strict',
}
max_message_size Maximum size in bytes for an incoming WebSocket message (0 = unlimited).
Type
int
Default
65536

Maximum size in bytes for an incoming WebSocket message (0 = unlimited). Default 64KB; protects against memory exhaustion from oversized payloads.

Python settings.py
DJUST_CONFIG = {
    'max_message_size': 131072,  # 128KB
}
rate_limit Global WebSocket rate limiting.
Type
dict
Default
{'rate': 100, 'burst': 20, 'max_warnings': 3, 'max_connections_per_ip': 10, 'reconnect_cooldown': 5}

Global WebSocket rate limiting. Keys include rate (events/sec), burst (bucket size), max_connections_per_ip and reconnect_cooldown. Mitigates floods and abusive reconnects.

Python settings.py
DJUST_CONFIG = {
    'rate_limit': {'rate': 50, 'burst': 10},
}
serialization_max_depth Maximum depth for nested model serialization (e.g.
Type
int
Default
3

Maximum depth for nested model serialization (e.g. lease.tenant.user is 3 levels). Prevents runaway recursion and bloat on circular relations.

Python settings.py
DJUST_CONFIG = {
    'serialization_max_depth': 2,
}
strict_serialization When False, non-serializable values are coerced via str() with a warning.
Type
bool
Default
False

When False, non-serializable values are coerced via str() with a warning. When True, they raise TypeError with an actionable message — useful to catch state bugs in development.

Python settings.py
DJUST_CONFIG = {
    'strict_serialization': True,
}
jit_serialization Enables JIT auto-serialization of Django models by the Rust engine at render time.
Type
bool
Default
True

Enables JIT auto-serialization of Django models by the Rust engine at render time. Disable only for testing or custom serialization.

Python settings.py
DJUST_CONFIG = {
    'jit_serialization': True,
}
jit_cache_backend Where compiled JIT serializers are cached (filesystem or redis).
Type
str
Default
'filesystem'

Where compiled JIT serializers are cached: 'filesystem' (default, fine for most) or 'redis' (for multi-worker deployments).

Python settings.py
DJUST_CONFIG = {
    'jit_cache_backend': 'redis',
}
hot_reload Dev-only (requires DEBUG=True): watches template and Python files and reloads the view in the browser on change.
Type
bool
Default
True

Dev-only (requires DEBUG=True): watches template and Python files and reloads the view in the browser on change. Auto-enabled at startup unless hot_reload_auto_enable is False.

Python settings.py
DJUST_CONFIG = {
    'hot_reload': True,
}
hvr_enabled Hot View Replacement — state-preserving Python code reload in dev.
Type
bool
Default
True

Hot View Replacement — state-preserving Python code reload in dev. Gated on DEBUG=True and hot_reload=True; reloads handler code without reconnecting or losing state.

Python settings.py
DJUST_CONFIG = {
    'hvr_enabled': True,
}
hook_namespacing Colocated JS-hook naming mode (lax bare names, or strict prefixes).
Type
str
Default
'lax'

Colocated JS-hook naming: 'lax' uses bare hook names; 'strict' prefixes them with the view's module + qualname to avoid collisions. Per-tag opt-out via {% colocated_hook 'X' global %}.

Python settings.py
DJUST_CONFIG = {
    'hook_namespacing': 'strict',
}
websocket_compression Declares intent to use WebSocket permessage-deflate (actual negotiation happens in the ASGI server).
Type
bool
Default
True

Declares intent to use WebSocket permessage-deflate (actual negotiation happens in the ASGI server). Costs ~64KB context per connection; disable at extreme connection density.

Python settings.py
DJUST_CONFIG = {
    'websocket_compression': True,
}
suppress_checks System-check IDs to silence (e.g.
Type
list[str]
Default
[] (opt-in; no framework default)

System-check IDs to silence (e.g. ['C013', 'T002']). Unlike the keys above it has no framework default — it's an opt-in list you add when a project deliberately skips a checked feature, such as serving client.min.js from a CDN.

Python settings.py
DJUST_CONFIG = {
    'suppress_checks': ['C013'],
}
service_worker Service-Worker features: VDOM snapshot cache and back-nav state restore.
Type
dict
Default
{'main_selector': 'main', 'shell_cache_name': 'djust-shell-v1', 'reconnect_buffer_cap': 50, 'vdom_cache_enabled': True, 'vdom_cache_ttl_seconds': 1800, 'vdom_cache_max_entries': 50, 'state_snapshot_enabled': True}

Service-Worker features: vdom_cache_enabled serves per-URL HTML snapshots instantly on popstate (reconciled against the live mount); state_snapshot_enabled powers back-button state restoration with LiveView.enable_state_snapshot.

Python settings.py
DJUST_CONFIG = {
    'service_worker': {
        'vdom_cache_enabled': True,
        'state_snapshot_enabled': True,
    },
}