SplitDateTimeWidget
A widget that splits datetime input into two < input type="text" > boxes.
Attributes
| Attribute | Type | Description |
|---|---|---|
| supports_microseconds | boolean = False | A boolean flag indicating whether the widget handles microsecond precision for datetime values, set to False by default. |
| template_name | string = django/forms/widgets/splitdatetime.html | The file path to the HTML template used to render the split date and time input fields. |
Constructor
Signature
def SplitDateTimeWidget(
attrs: dict = None,
date_format: str = None,
time_format: str = None,
date_attrs: dict = None,
time_attrs: dict = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| attrs | dict = None | Standard HTML attributes for the widget. |
| date_format | str = None | The format used to display the date value. |
| time_format | str = None | The format used to display the time value. |
| date_attrs | dict = None | Specific HTML attributes for the DateInput sub-widget. |
| time_attrs | dict = None | Specific HTML attributes for the TimeInput sub-widget. |
Signature
def SplitDateTimeWidget(
attrs: dict = None,
date_format: str = None,
time_format: str = None,
date_attrs: dict = None,
time_attrs: dict = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| attrs | dict = None | HTML attributes to be applied to both the date and time input elements. |
| date_format | str = None | The format string used to render the date portion of the datetime value. |
| time_format | str = None | The format string used to render the time portion of the datetime value. |
| date_attrs | dict = None | Specific HTML attributes to apply only to the date input element, overriding the general attrs. |
| time_attrs | dict = None | Specific HTML attributes to apply only to the time input element, overriding the general attrs. |
Methods
decompress()
@classmethod
def decompress(
value: datetime
) - > list
Splits a single combined datetime value into a list containing separate date and time objects for display in the sub-widgets.
Parameters
| Name | Type | Description |
|---|---|---|
| value | datetime | The combined datetime object to be split into date and time components. |
Returns
| Type | Description |
|---|---|
list | A list containing two elements: the date object and the time object, or [None, None] if the input value is empty. |