Input
Base class for all < input > widgets.
Attributes
| Attribute | Type | Description |
|---|---|---|
| input_type | string | The HTML input type attribute to be rendered, which subclasses must define to determine the widget's behavior. |
| template_name | string = django/forms/widgets/input.html | The path to the Django HTML template used to render the input widget. |
Constructor
Signature
def Input(
attrs: dict = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| attrs | dict = None | A dictionary containing HTML attributes to be set on the widget. |
Signature
def Input(
attrs: dict = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| attrs | dict = None | A 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
| Name | Type | Description |
|---|---|---|
| name | string | The name of the form field associated with this widget. |
| value | any | The current value of the field to be displayed in the input element. |
| attrs | dict | Additional HTML attributes to be merged into the final rendered element. |
Returns
| Type | Description |
|---|---|
dict | A dictionary containing the widget's state and configuration, including the 'type' attribute used in the template. |