DateTimeBaseInput
This class serves as a base for input widgets that handle date and time values, extending the standard text input functionality. It provides mechanisms for localizing input values based on specific format keys and supports optional microsecond precision. Users can initialize the class with custom attributes and formats to control how date-time data is rendered in forms.
Attributes
| Attribute | Type | Description |
|---|---|---|
| format_key | string = "" | The localization setting key used to retrieve the default date or time formatting string when no specific format is provided. |
| supports_microseconds | boolean = false | A boolean flag indicating whether the input widget should preserve and display microsecond precision for datetime values. |
Constructor
Signature
def DateTimeBaseInput(
attrs: dict = None,
format: str = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| attrs | dict = None | Optional dictionary of HTML attributes to be added to the rendered widget. |
| format | str = None | The format in which the datetime value should be displayed and parsed. |
Signature
def DateTimeBaseInput(
attrs: dict = None,
format: string = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| attrs | dict = None | A dictionary containing HTML attributes to be rendered on the input element. |
| format | string = None | The specific date/time format string used to render the value in the field. |
Methods
format_value()
@classmethod
def format_value(
value: any
) - > string
Converts the internal Python date/time object into a localized string representation suitable for display in an HTML input field.
Parameters
| Name | Type | Description |
|---|---|---|
| value | any | The date, time, or datetime object to be formatted for the input field. |
Returns
| Type | Description |
|---|---|
string | A localized string representation of the date/time value formatted according to the widget's configuration. |