summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSamriddha9619 <sumitkumartripathi0@gmail.com>2025-09-24 23:32:06 +0530
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2026-04-13 10:00:59 +0300
commit7dc826b9758d634623a6f5ca05d0ca2048a0ce48 (patch)
treea609b147d050dc8d4207c7d8c9517c36fffb6537 /docs
parentd61f33f03b3177afdf1d76153014bad4107b1224 (diff)
Fixed #33113 -- Documented usage and caveats of HTML5 date input in DateInput widget.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/widgets.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index 80047aabc5..c65063cd68 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -646,6 +646,29 @@ These widgets make use of the HTML elements ``input`` and ``textarea``.
:doc:`/topics/i18n/formatting`. ``%U``, ``%W``, and ``%j`` formats are not
supported by this widget.
+ .. admonition:: Using the HTML5 "date" input type
+
+ If you are targeting browsers that support the
+ `HTML5 "date" input type`_, you can override the ``input_type``
+ attribute to enable the browser’s native date picker::
+
+ class MyDateInput(forms.DateInput):
+ input_type = "date"
+ format = "%Y-%m-%d"
+
+ Alternatively::
+
+ DateInput(attrs={"type": "date"}, format="%Y-%m-%d")
+
+ HTML5 date inputs expect values in the ISO format ``YYYY-MM-DD``. If a
+ different format is provided, the field may appear empty even when a
+ value exists. Setting the ``format`` attribute controls how Django
+ provides the value, but the browser controls how it is displayed.
+ Hence, the ``format`` attribute and the :setting:`DATE_INPUT_FORMATS`
+ setting will have no effect on the displayed value.
+
+ .. _HTML5 "date" input type: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
+
``DateTimeInput``
~~~~~~~~~~~~~~~~~