Skip to main content

DateTimeWidgetContextMixin

This mixin provides a standardized way to enhance the context of date and time widgets by automatically associating them with a timezone warning help text. It modifies the widget's attributes to include an ARIA description, ensuring that accessibility metadata is consistently applied across form fields.

Methods


get_context()

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

Extends the widget context to include an ARIA accessibility attribute that links the input to a timezone warning help text element.

Parameters

NameTypeDescription
namestrThe name of the form field used to generate the unique ID for the timezone warning help text.
valueanyThe current value of the widget to be rendered in the template context.
attrsdictA dictionary of HTML attributes to be applied to the rendered widget element.

Returns

TypeDescription
dictA dictionary containing the template context for rendering the widget, including the updated aria-describedby attribute.