Skip to content

Form Classes

forms

HiddenModelForm(*args, **kwargs)

Bases: ModelForm

ModelForm that renders all fields as hidden inputs.

Useful for embedding form data in a page without visible fields, e.g. confirmation steps or passing data through intermediate views.

ReadOnlyModelForm(*args, **kwargs)

Bases: ModelForm

ModelForm that renders all fields as read-only text with hidden inputs.

Each field is replaced with a ReadOnlyInput widget that displays the value as plain text while preserving the value in a hidden <input> for form submission.

EnhancedBaseInlineFormSet

Bases: BaseInlineFormSet

Inline formset with queryset limiting for ForeignKey fields.

For saved (existing) rows, ForeignKey dropdowns are restricted to only the currently selected value, preventing users from changing already-saved relations. For new (unsaved) rows, a custom default queryset can be applied.

Attributes:

Name Type Description
limit_saved_queryset_value_fields

List of field names whose querysets should be limited to the current value on saved instances.

default_field_queryset

Dict mapping field names to default querysets for new (unsaved) inline rows.

limit_field_queryset_model_fields

Dict mapping field names to lists of model field names to pass to .only() for queryset optimization.