Forms#

next.dj wraps Django forms with a registry, a stable POST endpoint, and a re-render pipeline that survives validation failures. This section walks every layer of the system from the page module down to the dispatch backend. Read Forms overview first, then jump to the page that matches the part you are extending.

Concepts

Forms overview

The mental model behind actions, dispatch, and re-render.

Building forms

Actions

Register a handler with @action and decide which parameters to ask for. Also covers the access guards, the dynamic permission hooks, and the success contracts (success_url, success_message).

Form templates

Render a form with {% form %} and link several forms on a single page.

ModelForms

Use Django ModelForm for create and edit pages.

Plain forms

Use a plain Form for filter, search, voting, and bulk-operation pages.

Field components

Render a field through a next.dj component with ComponentWidget.

Formsets

Render and validate Django formsets through the same dispatch pipeline.

Multi-step

Form wizards

Route a sequence of forms across requests and finalise on the last step.

Wizard backend

Persist per-step draft data through the configured wizard backend.

Mechanics

Validation and re-render

What happens between a failing POST and the re-rendered origin page.

Extending

Frozen form specs

The frozen field, formset, and form specs for rendering a form in a custom template engine.

Action backends

Swap the validation pipeline through FORM_ACTION_BACKENDS.

Form signals

Every signal the forms subsystem emits, with payload details.