Skip to main content

Form

A collection of Fields, plus their associated data.

Constructor

Signature

def Form(
data: dict = null,
files: dict = null,
auto_id: str|bool = 'id_%s',
prefix: str = null,
initial: dict = null,
error_class: type = ErrorList,
label_suffix: str = null,
empty_permitted: bool = false,
field_order: list = null,
use_required_attribute: bool = null,
renderer: [BaseRenderer](../renderers/baserenderer.md?sid=django_forms_renderers_baserenderer) = null
) - > null

Parameters

NameTypeDescription
datadict = nullA dictionary-like object containing the data to be validated.
filesdict = nullA dictionary-like object containing uploaded file data.
auto_id`strbool` = 'id_%s'
prefixstr = nullA prefix to be prepended to all field names in the HTML representation.
initialdict = nullA dictionary containing initial values for the fields.
error_classtype = ErrorListThe class used to display error messages.
label_suffixstr = nullThe character(s) to append after every field label.
empty_permittedbool = falseWhether the form is allowed to be empty.
field_orderlist = nullA list of field names to define the order in which they are rendered.
use_required_attributebool = nullWhether to use the 'required' HTML attribute on inputs.
renderer[BaseRenderer](../renderers/baserenderer.md?sid=django_forms_renderers_baserenderer) = nullThe renderer instance used to render the form to HTML.

Signature

def Form(
data: dict = null,
files: dict = null,
auto_id: string|boolean = 'id_%s',
prefix: string = null,
initial: dict = null,
error_class: type = ErrorList,
label_suffix: string = null,
empty_permitted: boolean = false,
field_order: list,
use_required_attribute: boolean = null,
renderer: [BaseRenderer](../renderers/baserenderer.md?sid=django_forms_renderers_baserenderer) = null
) - > null

Parameters

NameTypeDescription
datadict = nullA dictionary-like object containing the submitted form data to be validated.
filesdict = nullA dictionary-like object containing uploaded file data.
auto_id`stringboolean` = 'id_%s'
prefixstring = nullA string used to namespace form fields, preventing name collisions when multiple forms are rendered in one view.
initialdict = nullA dictionary of initial values to populate form fields when the form is unbound.
error_classtype = ErrorListThe class used to render and manage form error messages.
label_suffixstring = nullA string to append to every field label when the form is rendered.
empty_permittedboolean = falseIf true, the form is allowed to be empty and will not raise validation errors if no data is provided.
field_orderlistA list of field names specifying the order in which fields should be rendered.
use_required_attributeboolean = nullDetermines whether to add the 'required' HTML attribute to required field widgets.
renderer[BaseRenderer](../renderers/baserenderer.md?sid=django_forms_renderers_baserenderer) = nullThe engine used to render the form into HTML templates.