Skip to main content

SplitDateTimeWidget

A widget that splits datetime input into two < input type="text" > boxes.

Attributes

AttributeTypeDescription
supports_microsecondsboolean = FalseA boolean flag indicating whether the widget handles microsecond precision for datetime values, set to False by default.
template_namestring = django/forms/widgets/splitdatetime.htmlThe 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

NameTypeDescription
attrsdict = NoneStandard HTML attributes for the widget.
date_formatstr = NoneThe format used to display the date value.
time_formatstr = NoneThe format used to display the time value.
date_attrsdict = NoneSpecific HTML attributes for the DateInput sub-widget.
time_attrsdict = NoneSpecific 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

NameTypeDescription
attrsdict = NoneHTML attributes to be applied to both the date and time input elements.
date_formatstr = NoneThe format string used to render the date portion of the datetime value.
time_formatstr = NoneThe format string used to render the time portion of the datetime value.
date_attrsdict = NoneSpecific HTML attributes to apply only to the date input element, overriding the general attrs.
time_attrsdict = NoneSpecific 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

NameTypeDescription
valuedatetimeThe combined datetime object to be split into date and time components.

Returns

TypeDescription
listA list containing two elements: the date object and the time object, or [None, None] if the input value is empty.