File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -646,6 +646,29 @@ These widgets make use of the HTML elements ``input`` and ``textarea``.
646646 :doc:`/topics/i18n/formatting`. ``%U``, ``%W``, and ``%j`` formats are not
647647 supported by this widget.
648648
649+ .. admonition:: Using the HTML5 "date" input type
650+
651+ If you are targeting browsers that support the
652+ `HTML5 "date" input type`_, you can override the ``input_type``
653+ attribute to enable the browser’s native date picker::
654+
655+ class MyDateInput(forms.DateInput):
656+ input_type = "date"
657+ format = "%Y-%m-%d"
658+
659+ Alternatively::
660+
661+ DateInput(attrs={"type": "date"}, format="%Y-%m-%d")
662+
663+ HTML5 date inputs expect values in the ISO format ``YYYY-MM-DD``. If a
664+ different format is provided, the field may appear empty even when a
665+ value exists. Setting the ``format`` attribute controls how Django
666+ provides the value, but the browser controls how it is displayed.
667+ Hence, the ``format`` attribute and the :setting:`DATE_INPUT_FORMATS`
668+ setting will have no effect on the displayed value.
669+
670+ .. _HTML5 "date" input type: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
671+
649672``DateTimeInput``
650673~~~~~~~~~~~~~~~~~
651674
You can’t perform that action at this time.
0 commit comments