Skip to main content

Input

Base class for all < input > widgets.

Attributes

AttributeTypeDescription
input_typestringThe HTML input type attribute to be rendered, which subclasses must define to determine the widget's behavior.
template_namestring = django/forms/widgets/input.htmlThe path to the Django HTML template used to render the input widget.

Constructor

Signature

def Input(
attrs: dict = None
) - > null

Parameters

NameTypeDescription
attrsdict = NoneA dictionary containing HTML attributes to be set on the widget.

Signature

def Input(
attrs: dict = None
) - > null

Parameters

NameTypeDescription
attrsdict = NoneA dictionary of HTML attributes to be set on the rendered widget, which may include a 'type' key to override the default input type.

Methods


get_context()

@classmethod
def get_context(
name: string,
value: any,
attrs: dict
) - > dict

Builds the template context dictionary for rendering the widget, ensuring the specific input type is included for the HTML element.

Parameters

NameTypeDescription
namestringThe name of the form field associated with this widget.
valueanyThe current value of the field to be displayed in the input element.
attrsdictAdditional HTML attributes to be merged into the final rendered element.

Returns

TypeDescription
dictA dictionary containing the widget's state and configuration, including the 'type' attribute used in the template.