[Django] #33113: Add example to documentation of a DateInput with input_type='date'

2 views
Skip to first unread message

Django

unread,
Sep 16, 2021, 3:53:37 AM9/16/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
-----------------------------------------+------------------------
Reporter: dvg | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
== Rationale

By default, the `forms.widgets.DateInput` widget renders as a simple text
field.

However, a "date picker", like
[https://github.com/django/django/blob/stable/3.2.x/django/contrib/admin/widgets.py#L49
the one implemented in contrib.admin] is often much more convenient.

Fortunately it is now possible to take advantage of the browser's built-in
date picker, using the HTML [https://developer.mozilla.org/en-
US/docs/Web/HTML/Element/input/date <input type='date'>] element.

The only problem is that, although the default `DateInput` can be easily
modified to use the `<input type='date'>` element, this may not be so
obvious to people unfamiliar with the inner workings of Django (e.g.
[https://github.com/django/django/blob/stable/3.2.x/django/forms/widgets.py#L288
forms.widgets.Input.input_type]).

Moreover, some people may not even know the HTML `type='date'` exists, nor
that [https://developer.mozilla.org/en-
US/docs/Web/HTML/Element/input/date#browser_compatibility browsers have
built-in date pickers].

== Request

I believe it would be very helpful if the documentation included an
example, like [https://code.djangoproject.com/ticket/33100#comment:6 these
two provided by Tim Graham in ticket #33100]:


{{{
class DateInput(forms.DateInput):
input_type = 'date'
}}}

or

{{{
DateInput(attrs={'type': 'date'})
}}}


This has the additional advantage of documenting the use of the
`forms.widgets.Input.input_type` attribute, which
[https://github.com/django/django/blob/stable/3.2.x/docs/ref/forms/widgets.txt#L507
appears in the documentation] but is not mentioned explicitly in the text,
as far as I see.

If necessary, I would be willing to prepare a pull request for this.

--
Ticket URL: <https://code.djangoproject.com/ticket/33113>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 16, 2021, 6:09:22 AM9/16/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
-------------------------------+--------------------------------------

Reporter: dvg | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by dvg:

Old description:

> == Rationale
>
> By default, the `forms.widgets.DateInput` widget renders as a simple text
> field.
>
> However, a "date picker", like
> [https://github.com/django/django/blob/stable/3.2.x/django/contrib/admin/widgets.py#L49
> the one implemented in contrib.admin] is often much more convenient.
>
> Fortunately it is now possible to take advantage of the browser's built-

> in date picker, using the HTML [https://developer.mozilla.org/en-


> US/docs/Web/HTML/Element/input/date <input type='date'>] element.
>
> The only problem is that, although the default `DateInput` can be easily
> modified to use the `<input type='date'>` element, this may not be so
> obvious to people unfamiliar with the inner workings of Django (e.g.
> [https://github.com/django/django/blob/stable/3.2.x/django/forms/widgets.py#L288
> forms.widgets.Input.input_type]).
>
> Moreover, some people may not even know the HTML `type='date'` exists,
> nor that [https://developer.mozilla.org/en-
> US/docs/Web/HTML/Element/input/date#browser_compatibility browsers have
> built-in date pickers].
>
> == Request
>
> I believe it would be very helpful if the documentation included an
> example, like [https://code.djangoproject.com/ticket/33100#comment:6
> these two provided by Tim Graham in ticket #33100]:
>

> {{{
> class DateInput(forms.DateInput):
> input_type = 'date'
> }}}
>
> or
>
> {{{
> DateInput(attrs={'type': 'date'})
> }}}
>

>

> This has the additional advantage of documenting the use of the
> `forms.widgets.Input.input_type` attribute, which
> [https://github.com/django/django/blob/stable/3.2.x/docs/ref/forms/widgets.txt#L507
> appears in the documentation] but is not mentioned explicitly in the
> text, as far as I see.
>
> If necessary, I would be willing to prepare a pull request for this.

New description:

== Rationale

By default, the
[https://docs.djangoproject.com/en/3.2/ref/forms/widgets/#dateinput

== Request

or

{{{
DateInput(attrs={'type': 'date'})
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:1>

Django

unread,
Sep 17, 2021, 2:15:18 AM9/17/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Claude Paroz):

* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Yes, please. A note about why Django doesn't use this input type by
default would be nice too.

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:2>

Django

unread,
Sep 17, 2021, 3:02:05 AM9/17/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: dvg
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by dvg):

* owner: nobody => dvg
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:3>

Django

unread,
Sep 27, 2021, 5:11:28 AM9/27/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: dvg
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by dvg):

Replying to [comment:2 Claude Paroz]:


> Yes, please. A note about why Django doesn't use this input type by
default would be nice too.

Would something like
[https://github.com/dennisvang/django/commit/b7a7cbb23bf2dbfbf128ea260de8208cd6f65e73
this] do?

I'm not quite sure how to explain why `input_type = 'date'` is not the
default.

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:4>

Django

unread,
Sep 27, 2021, 7:17:22 AM9/27/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: dvg
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by dvg):

* has_patch: 0 => 1


Comment:

Pull request: https://github.com/django/django/pull/14905

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:5>

Django

unread,
Sep 28, 2021, 4:14:22 AM9/28/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: dvg
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:6>

Django

unread,
Oct 4, 2021, 3:55:09 AM10/4/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: dvg
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Claude Paroz):

#33165 is a typical issue showing the difficulty of the `date` input. So
the simple widget subclass with `input_type = 'date'` is NOT sufficient to
make it work properly. The initial input value must also be converted to
the `YYYY-MM-DD` format to comply with the [https://developer.mozilla.org
/en-US/docs/Web/HTML/Element/input/date specs].

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:7>

Django

unread,
Oct 12, 2021, 9:24:10 AM10/12/21
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
--------------------------------------+------------------------------------
Reporter: dvg | Owner: dvg
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

There was a [https://groups.google.com/g/django-developers/c/wp-
pnzcB25o/m/D5gEOzPIAQAJ?utm_medium=email&utm_source=footer mailing list
discussion] raising some points, as well as those here and on the PR.

Capturing those succinctly is the remaining task here.

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:8>

Django

unread,
Sep 29, 2023, 8:58:37 AM9/29/23
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
-------------------------------------+-------------------------------------
Reporter: dennisvang | Owner:
Type: | dennisvang
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Natalia Bidart):

Pinged PR author to see if we can revive this effort (following recent
ticket #34853).

--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:9>

Django

unread,
Sep 29, 2023, 8:59:04 AM9/29/23
to django-...@googlegroups.com
#33113: Add example to documentation of a DateInput with input_type='date'
-------------------------------------+-------------------------------------
Reporter: dennisvang | Owner:
Type: | dennisvang
Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* version: 3.2 => dev


--
Ticket URL: <https://code.djangoproject.com/ticket/33113#comment:10>

Reply all
Reply to author
Forward
0 new messages