---
# GENERATED FILE — do not edit.
# Source: `manage.py docs_generate` (djust 1.3.0rc5).
# Edit the generator in docs_app/generator.py instead.
title: "Mixin reference"
description: "Every LiveView mixin: what it adds and its public methods, generated."
level: reference
order: 85
section: reference
generated: true
---
The mixins a LiveView is built from, generated from the framework's classes.

Add an opt-in mixin before `LiveView` in the class bases. The built-in ones
are already part of every `LiveView`: their methods are on `self` with no
import.

```python
from djust import FormMixin, LiveView

class ContactView(FormMixin, LiveView):
    form_class = ContactForm
```

## Opt-in mixins (9)

### `ReactMixin`

`from djust import ReactMixin`

Mixin for LiveView classes to add React component support.

#### `get_react_components`

```text
self.get_react_components() -> djust.react.ReactComponentRegistry
```

Override to provide custom component registry.

#### `render_react_component`

```text
self.render_react_component(name: str, props: Dict[str, Any], children: str = '') -> str
```

Render a React component within this view.

### `FormMixin`

`from djust import FormMixin`

Mixin for LiveView classes to add Django Forms support with real-time validation.

#### `get_context_data`

```text
self.get_context_data(**kwargs: Any) -> Dict[str, Any]
```

Provide the form's keys to explicit templates; legacy is unchanged.

#### `mount`

```text
self.mount(request: Any, **kwargs: Any) -> None
```

Initialize form on view mount

#### `form_instance`

Property, settable. Access the form instance (re-creates if lost after serialization).

#### `get_form_class`

```text
self.get_form_class() -> Optional[Type[django.forms.forms.Form]]
```

Return the configured form class; override for dynamic forms.

#### `get_initial`

```text
self.get_initial() -> Dict[str, Any]
```

Return a fresh initial-value mapping, following Django's form hook.

#### `get_prefix`

```text
self.get_prefix() -> Optional[str]
```

Return the HTML field-name prefix, if configured.

#### `get_form_kwargs`

```text
self.get_form_kwargs() -> Dict[str, Any]
```

Build form arguments for initial rendering or the current event.

#### `get_form`

```text
self.get_form(
    form_class: Optional[Type[django.forms.forms.Form]] = None,
) -> django.forms.forms.Form
```

Construct a form through the public class, initial, prefix and kwargs hooks.

#### `validate_field`

```text
self.validate_field(
    field: str = '',
    field_name: str = '',
    value: Any = None,
    **kwargs: Any,
) -> None
```

Validate a single field in real-time.

#### `submit_form`

```text
self.submit_form(**kwargs: Any) -> None
```

Handle form submission.

#### `reset_form`

```text
self.reset_form(**kwargs: Any) -> None
```

Reset the form to its initial state.

#### `get_field_value`

```text
self.get_field_value(field_name: str, default: Any = '') -> Any
```

Get current value for a field

#### `get_field_errors`

```text
self.get_field_errors(field_name: str) -> List[str]
```

Get errors for a specific field

#### `has_field_errors`

```text
self.has_field_errors(field_name: str) -> bool
```

Check if a field has errors

#### `as_live`

```text
self.as_live(**kwargs: Any) -> str
```

Render the entire form automatically using the configured CSS framework.

#### `as_live_field`

```text
self.as_live_field(field_name: str, adapter: Any = None, **kwargs: Any) -> str
```

Render a single form field automatically using the configured CSS framework.

### `WizardMixin`

`from djust import WizardMixin`

Multi-step form wizard mixin for djust LiveViews.

#### `mount`

```text
self.mount(request: Any, **kwargs: Any) -> None
```

Initialise wizard state on first load.

#### `as_live_field`

```text
self.as_live_field(
    field_name: str,
    event_name: str = 'validate_field',
    **kwargs: Any,
) -> str
```

Render a form field as HTML with djust event bindings.

#### `get_context_data`

```text
self.get_context_data(**kwargs: Any) -> Dict[str, Any]
```

Inject wizard state into the template context.

#### `next_step`

```text
self.next_step(**kwargs: Any) -> None
```

Validate the current step and advance to the next one.

#### `prev_step`

```text
self.prev_step(**kwargs: Any) -> None
```

Go back one step without validation.

#### `go_to_step`

```text
self.go_to_step(step_index: int = 0, **kwargs: Any) -> None
```

Jump to a specific already-completed step for editing.

#### `update_step_field`

```text
self.update_step_field(field: str = '', value: Any = '', **kwargs: Any) -> None
```

Store a single field value for the current step.

#### `validate_field`

```text
self.validate_field(
    field: str = '',
    field_name: str = '',
    value: Any = '',
    **kwargs: Any,
) -> None
```

Store a field value triggered by as_live_field() dj-change events.

#### `submit_wizard`

```text
self.submit_wizard(**kwargs: Any) -> None
```

Validate all steps and call on_wizard_complete() if everything passes.

#### `on_wizard_complete`

```text
self.on_wizard_complete(step_data: dict[str, typing.Any]) -> None
```

Called when the wizard is fully completed and all steps are valid.

### `DraftModeMixin`

`from djust import DraftModeMixin`

Mixin for LiveView classes to enable automatic draft saving to localStorage.

#### `get_draft_key`

```text
self.get_draft_key() -> str
```

Get the draft key for localStorage.

#### `clear_draft`

```text
self.clear_draft() -> None
```

Clear the draft from localStorage.

#### `get_context_data`

```text
self.get_context_data(**kwargs: Any) -> dict[str, typing.Any]
```

Add draft configuration to template context.

### `PresenceMixin`

`from djust import PresenceMixin`

Mixin that provides presence tracking capabilities to LiveView.

#### `get_presence_key`

```text
self.get_presence_key() -> str
```

Get the presence key for this view instance.

#### `get_presence_user_id`

```text
self.get_presence_user_id() -> str
```

Get the unique user identifier for presence tracking.

#### `track_presence`

```text
self.track_presence(meta: Optional[Dict[str, Any]] = None) -> None
```

Start tracking this user's presence.

#### `untrack_presence`

```text
self.untrack_presence() -> None
```

Stop tracking this user's presence.

#### `list_presences`

```text
self.list_presences() -> List[Dict[str, Any]]
```

Get all active presences for this view's presence group.

#### `presence_count`

```text
self.presence_count() -> int
```

Get the count of active users in this view's presence group.

#### `update_presence_heartbeat`

```text
self.update_presence_heartbeat() -> None
```

Update the heartbeat for this user's presence.

#### `handle_presence_join`

```text
self.handle_presence_join(presence: Dict[str, Any]) -> None
```

Called when a user joins the presence group.

#### `handle_presence_leave`

```text
self.handle_presence_leave(presence: Dict[str, Any]) -> None
```

Called when a user leaves the presence group.

#### `broadcast_to_presence`

```text
self.broadcast_to_presence(event: str, payload: Optional[Dict[str, Any]] = None) -> None
```

Broadcast an event to all users in the presence group.

### `LiveCursorMixin`

`from djust import LiveCursorMixin`

Extends PresenceMixin with live cursor tracking capabilities.

#### `update_cursor_position`

```text
self.update_cursor_position(x: int, y: int) -> None
```

Update cursor position for this user.

#### `get_cursors`

```text
self.get_cursors() -> Dict[str, Dict[str, Any]]
```

Get all active cursor positions for this presence group.

#### `handle_cursor_move`

```text
self.handle_cursor_move(x: int, y: int) -> None
```

Handler called when cursor position is received from client.

#### `untrack_presence`

```text
self.untrack_presence() -> None
```

Override to also remove cursor when leaving presence.

### `UploadMixin`

`from djust import UploadMixin`

Mixin that adds file upload support to a LiveView.

#### `allow_upload`

```text
self.allow_upload(
    name: str,
    accept: str = '',
    max_entries: int = 1,
    max_file_size: int = 10000000,
    chunk_size: int = 65536,
    auto_upload: bool = True,
    writer: Optional[Type[djust.uploads.UploadWriter]] = None,
    resumable: bool = False,
    allow_active_content: bool = False,
) -> djust.uploads.UploadConfig
```

Configure a named upload slot.

#### `consume_uploaded_entries`

```text
self.consume_uploaded_entries(
    name: str,
) -> Generator[djust.uploads.UploadEntry, NoneType, NoneType]
```

Consume completed upload entries for the named slot.

#### `cancel_upload`

```text
self.cancel_upload(name: str, ref: str) -> None
```

Cancel a specific upload by ref.

#### `get_uploads`

```text
self.get_uploads(name: str) -> List[djust.uploads.UploadEntry]
```

Get all entries (including in-progress) for an upload slot.

### `LoginRequiredMixin`

`from djust import LoginRequiredMixin`

Mixin that sets login_required = True. Django-familiar convenience.

### `PermissionRequiredMixin`

`from djust import PermissionRequiredMixin`

Mixin that enforces permission_required. Set the attribute on your view.

## Built into LiveView (22)

### `ContextProviderMixin`

Included in `LiveView`.

Component/view context sharing — React Context API equivalent (v0.5.1).

#### `provide_context`

```text
self.provide_context(key: str, value: Any) -> None
```

Expose a value to descendant components under `key`.

#### `consume_context`

```text
self.consume_context(key: str, default: Any = None) -> Any
```

Return the value provided under `key` by this node or any ancestor.

#### `clear_context_providers`

```text
self.clear_context_providers() -> None
```

Reset all context providers — called at the start of each render.

### `StreamsMixin`

Included in `LiveView`. To name it, `from djust.mixins import StreamsMixin`.

Methods for managing streams: stream, stream_insert, stream_delete, stream_reset.

#### `stream`

```text
self.stream(
    name: str,
    items: Any,
    dom_id: Optional[Callable[[Any], str]] = None,
    at: int = -1,
    reset: bool = False,
    limit: Optional[int] = None,
) -> djust.session_utils.Stream
```

Initialize or update a stream with items.

#### `stream_prune`

```text
self.stream_prune(name: str, limit: int, edge: str = 'top') -> None
```

Cap a stream at `limit` items, removing the surplus rows from the page on the next render.

#### `stream_insert`

```text
self.stream_insert(name: str, item: Any, at: int = -1) -> None
```

Insert an item into a stream (-1 = append, 0 = prepend).

#### `stream_delete`

```text
self.stream_delete(name: str, item_or_id: Any) -> None
```

Delete an item from a stream by item or id.

#### `stream_reset`

```text
self.stream_reset(name: str, items: Any = None) -> None
```

Reset a stream, clearing all items and optionally adding new ones.

### `StreamingMixin`

Included in `LiveView`. To name it, `from djust import StreamingMixin`.

Mixin that provides streaming capabilities for LiveView.

#### `stream_to`

```text
self.stream_to(
    stream_name: str,
    target: Optional[str] = None,
    html: Optional[str] = None,
) -> None
```

Send a streaming partial update to the client.

#### `stream_text`

```text
self.stream_text(
    stream_name: str,
    text: str,
    mode: str = 'append',
    target: Optional[str] = None,
) -> None
```

Stream text content to a target element.

#### `stream_error`

```text
self.stream_error(stream_name: str, error: str, target: Optional[str] = None) -> None
```

Send an error state to a stream target, preserving partial content.

#### `stream_start`

```text
self.stream_start(stream_name: str, target: Optional[str] = None) -> None
```

Signal the start of a stream to the client.

#### `stream_done`

```text
self.stream_done(stream_name: str, target: Optional[str] = None) -> None
```

Signal the end of a stream to the client.

#### `push_state`

```text
self.push_state() -> None
```

Send current state to the client immediately (full re-render).

### `TemplateMixin`

Included in `LiveView`. To name it, `from djust.mixins import TemplateMixin`.

Template-related methods: get_template, render, render_full_template, render_with_diff, and various HTML extraction/stripping helpers.

#### `get_template`

```text
self.get_template() -> str
```

Get the Rust template source for this view.

#### `render`

```text
self.render(request: Optional[ForwardRef('HttpRequest')] = None) -> str
```

Render the view to HTML.

#### `arender_chunks`

```text
self.arender_chunks(full_html: str, emitter: 'ChunkEmitter') -> None
```

Async-generator producer that pushes shell-then-body chunks.

#### `render_full_template`

```text
self.render_full_template(
    request: Optional[ForwardRef('HttpRequest')] = None,
    serialized_context: Optional[Dict[str, Any]] = None,
) -> str
```

Render the full template including base template inheritance. Used for initial GET requests when using template inheritance.

#### `render_with_diff`

```text
self.render_with_diff(
    request: Optional[ForwardRef('HttpRequest')] = None,
    extract_liveview_root: bool = False,
    preloaded_context: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Optional[str], int]
```

Render the view and compute diff from last render.

### `ComponentMixin`

Included in `LiveView`. To name it, `from djust.mixins import ComponentMixin`.

Component methods: mount, handle_component_event, update_component, etc.

#### `mount`

```text
self.mount(request: 'HttpRequest', **kwargs: Any) -> None
```

Called when the view is mounted. Override to set initial state.

#### `handle_component_event`

```text
self.handle_component_event(component_id: str, event: str, data: Dict[str, Any]) -> None
```

Handle events sent from child components.

#### `update_component`

```text
self.update_component(component_id: str, **props: Any) -> None
```

Update a child component's props.

### `ContextMixin`

Included in `LiveView`. To name it, `from djust.mixins import ContextMixin`.

Context methods: get_context_data, _get_context_processors, _apply_context_processors.

#### `get_context_data`

```text
self.get_context_data(**kwargs: Any) -> Dict[str, Any]
```

Get the context data for rendering. Override to customize context.

### `RustBridgeMixin`

Included in `LiveView`. To name it, `from djust.mixins import RustBridgeMixin`.

Rust integration: _initialize_rust_view, _sync_state_to_rust.

#### `set_changed_keys`

```text
self.set_changed_keys(keys: Union[str, Iterable[str], NoneType] = None) -> None
```

Mark one or more public attrs as changed, forcing a re-render.

### `RequestMixin`

Included in `LiveView`. To name it, `from djust.mixins import RequestMixin`.

HTTP handling: get, post.

#### `get`

```text
self.get(
    request: 'HttpRequest',
    *args: Any,
    **kwargs: Any,
) -> django.http.response.HttpResponse
```

Handle GET requests - initial page load.

#### `aget`

```text
self.aget(
    request: 'HttpRequest',
    *args: Any,
    **kwargs: Any,
) -> django.http.response.HttpResponse
```

Async-streaming GET path. PR-A foundation (ADR-015).

#### `post`

```text
self.post(
    request: 'HttpRequest',
    *args: Any,
    **kwargs: Any,
) -> django.http.response.HttpResponse
```

Handle POST requests - event handling

### `PostProcessingMixin`

Included in `LiveView`. To name it, `from djust.mixins import PostProcessingMixin`.

Post-processing: get_debug_info, _hydrate_react_components, _inject_client_script.

#### `get_debug_info`

```text
self.get_debug_info() -> Dict[str, Any]
```

Get debug information about this LiveView instance.

#### `get_debug_update`

```text
self.get_debug_update() -> Dict[str, Any]
```

Get a slim debug payload for event responses (skip static handler metadata).

### `ModelBindingMixin`

Included in `LiveView`. To name it, `from djust.mixins import ModelBindingMixin`.

Provides automatic `update_model` handler for dj-model bindings.

#### `update_model`

```text
self.update_model(field: str = '', value: Any = None, **kwargs: Any) -> None
```

Default handler for dj-model changes from the client.

### `PushEventMixin`

Included in `LiveView`. To name it, `from djust.mixins import PushEventMixin`.

Mixin that provides push_event() for sending events to client JS.

#### `push_event`

```text
self.push_event(event: str, payload: Dict[str, Any] = None) -> None
```

Push an event to the connected client(s).

#### `trigger_submit`

```text
self.trigger_submit(selector: str) -> None
```

Trigger a native HTML form POST on the client after this handler.

#### `push_commands`

```text
self.push_commands(chain: 'JSChain') -> None
```

Push a JS Command chain to the current session for immediate execution.

#### `flush_push_events`

```text
self.flush_push_events() -> None
```

Flush pending push events immediately via the consumer callback.

### `NavigationMixin`

Included in `LiveView`. To name it, `from djust.mixins import NavigationMixin`.

Adds URL navigation capabilities to a LiveView.

#### `live_patch`

```text
self.live_patch(
    params: Optional[Dict[str, Any]] = None,
    path: Optional[str] = None,
    replace: bool = False,
) -> None
```

Update the browser URL without remounting the view.

#### `live_redirect`

```text
self.live_redirect(
    path: str,
    params: Optional[Dict[str, Any]] = None,
    replace: bool = False,
) -> None
```

Navigate to a different LiveView over the existing WebSocket.

#### `handle_params`

```text
self.handle_params(params: Dict[str, Any], uri: str) -> None
```

Called after mount() on initial render AND on every subsequent URL change.

### `FlashMixin`

Included in `LiveView`. To name it, `from djust import FlashMixin`.

Mixin that provides put_flash() and clear_flash() for LiveView.

#### `put_flash`

```text
self.put_flash(level: str, message: str) -> None
```

Queue a flash message to be sent to the connected client.

#### `clear_flash`

```text
self.clear_flash(level: Optional[str] = None) -> None
```

Queue a command to clear flash messages on the client.

### `PageMetadataMixin`

Included in `LiveView`. To name it, `from djust import PageMetadataMixin`.

Mixin that provides page_title and page_meta property setters for LiveView.

#### `page_title`

Property, settable. Get the current page title.

#### `page_meta`

Property, settable. Get the current page meta tags.

### `LayoutMixin`

Included in `LiveView`. To name it, `from djust.mixins import LayoutMixin`.

Mixin exposing :meth:`set_layout` for runtime layout switching.

#### `set_layout`

```text
self.set_layout(template_path: str) -> None
```

Queue a layout swap to be applied after the current handler returns.

### `WaiterMixin`

Included in `LiveView`. To name it, `from djust.mixins import WaiterMixin`.

Adds `wait_for_event` to a LiveView.

#### `wait_for_event`

```text
self.wait_for_event(
    name: 'str',
    *,
    timeout: 'Optional[float]' = None,
    predicate: 'Optional[Callable[[Dict[str, Any]], bool]]' = None,
) -> 'Dict[str, Any]'
```

Suspend until an `@event_handler` named `name` is called.

### `AsyncWorkMixin`

Included in `LiveView`. To name it, `from djust.mixins import AsyncWorkMixin`.

Mixin that provides start_async() for running slow work after flushing current state to the client.

#### `start_async`

```text
self.start_async(
    callback: Callable[..., Any],
    *args: Any,
    name: Optional[str] = None,
    **kwargs: Any,
) -> None
```

Schedule a callback to run in a background thread after the current handler's state is flushed to the client.

#### `cancel_async`

```text
self.cancel_async(name: str) -> None
```

Cancel a scheduled or running async task.

#### `cancel_async_all`

```text
self.cancel_async_all() -> None
```

Cancel every scheduled and running `start_async` task on this view.

#### `defer`

```text
self.defer(callback: Callable[..., Any], *args: Any, **kwargs: Any) -> None
```

Schedule a callback to run **once, after the current render+patch cycle** completes. Phoenix-style `send(self(), :foo)` semantics — useful for telemetry, post-render cleanup, or follow-up side effects that should fire after the user sees the change.

#### `assign_async`

```text
self.assign_async(
    name: str,
    loader: Callable[..., Any],
    *args: Any,
    **kwargs: Any,
) -> None
```

High-level async data loading with built-in loading / ok / failed state.

### `NotificationMixin`

Included in `LiveView`. To name it, `from djust import NotificationMixin`.

Subscribe a LiveView to PostgreSQL `pg_notify` channels.

#### `listen`

```text
self.listen(channel: str) -> None
```

Subscribe this view to pg_notify on `channel`.

#### `handle_info`

```text
self.handle_info(message: Dict[str, Any]) -> None
```

Receive out-of-band messages (e.g. pg_notify events).

### `ActivityMixin`

Included in `LiveView`. To name it, `from djust.mixins import ActivityMixin`.

Per-LiveView registry of `{% dj_activity %}` regions.

#### `set_activity_visible`

```text
self.set_activity_visible(name: 'str', visible: 'bool') -> 'None'
```

Flip the server-side visibility state of an activity.

#### `is_activity_visible`

```text
self.is_activity_visible(name: 'str') -> 'bool'
```

Return the DECLARED visibility of an activity.

### Internal

Also bases of `LiveView`, contributing no public methods to it: `JITMixin`, `HandlerMixin`, `StickyChildRegistry`.
