[Django] #35293: Django 5.x changes the date format on an <input type="date"> from "2012-10-01" to "01/10/2012"

18 views
Skip to first unread message

Django

unread,
Mar 12, 2024, 6:52:39 AM3/12/24
to django-...@googlegroups.com
#35293: Django 5.x changes the date format on an <input type="date"> from
"2012-10-01" to "01/10/2012"
-------------------------------------------+------------------------
Reporter: Shaheed Haque | Owner: nobody
Type: Uncategorized | Status: new
Component: Template system | Version: 5.0
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 |
-------------------------------------------+------------------------
We are attempting to migrate from Django 4.11 to Django 5.0.latest. Our
tests identified that Date inputs which were previous rendered with a
"value" attribute in ISO8601 date format now seem to be rendered using en-
GB. Here is what the 4.x renders:

{{{
<input type="date" name="..." value="2012-10-01" class=" form-control"
required="" id="...">
}}}

versus what 5.x renders:

{{{
<input type="date" name="..." value="01/10/2012" class=" form-control"
required="" aria-describedby="..." id="...">
}}}

Our settings have not changed. Here is a subset of what we have:

{{{
LANGUAGE_CODE = 'en-gb'
LANGUAGES = (
('en-gb', _('English (GB)')),
)
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = False
USE_TZ = True
}}}

Note that we do NOT have any of the DATE_FORMAT, DATE_INPUT_FORMATS etc.
set, so they should have their default values. I have reviewed the release
notes but did not see anything relevant. I have tried debugging the code
in django.utils.formats but is not clear to me where the difference
originates.

In case it is relevant, we are using the Jinja backend with bootstrap
styling and our own templates, but the core "field" rendering should be
whatever Django does.
--
Ticket URL: <https://code.djangoproject.com/ticket/35293>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 12, 2024, 7:07:08 AM3/12/24
to django-...@googlegroups.com
#35293: Django 5.x changes the date format on an <input type="date"> from
"2012-10-01" to "01/10/2012"
---------------------------------+--------------------------------------
Reporter: Shaheed Haque | Owner: nobody
Type: Bug | Status: closed
Component: Template system | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Tim Graham):

* resolution: => needsinfo
* status: new => closed
* type: Uncategorized => Bug

Comment:

The description mentions Django 4.11 but this isn't a valid version. Did
you mean 4.1?

This looks relevant from the Djagno 5.0 release notes, "The USE_L10N
setting is removed." (8d98f99a4ab5de6f2c730399f53eba8bf6bea470) Did you
test your project with deprecation warnings enabled? Does the behavior
change in Django 4.x if setting `USE_L10N=True`.

If that's not the cause, you can try
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#bisecting-a-regression bisecting] to find the commit where the
behavior changed.

If you need help debugging, see TicketClosingReasons/UseSupportChannels
and reopen the ticket if you determine this is a bug in Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/35293#comment:1>

Django

unread,
Mar 12, 2024, 7:12:07 AM3/12/24
to django-...@googlegroups.com
#35293: Django 5.x changes the date format on an <input type="date"> from
"2012-10-01" to "01/10/2012"
---------------------------------+--------------------------------------
Reporter: Shaheed Haque | Owner: nobody
Type: Bug | Status: closed
Component: Template system | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by David Sanders):

To further Tim's points, if you look back at the 4.0 release notes it
documents that `USE_L10N = True` is the _default_ behaviour which means
that in Django 5.0 you now need to override where Django finds its
localisation if you want to preserve the "old default" values for
`DATE_FORMAT`, etc.

Please see: https://docs.djangoproject.com/en/5.0/topics/i18n/formatting
/#creating-custom-format-files
--
Ticket URL: <https://code.djangoproject.com/ticket/35293#comment:2>

Django

unread,
Mar 12, 2024, 7:52:34 AM3/12/24
to django-...@googlegroups.com
#35293: Django 5.x changes the date format on an <input type="date"> from
"2012-10-01" to "01/10/2012"
---------------------------------+--------------------------------------
Reporter: Shaheed Haque | Owner: nobody
Type: Bug | Status: closed
Component: Template system | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by Shaheed Haque):

FWIW, I meant to say I was running version 4.2.11, but I had not spotted
the need to create custom format files. Thanks for the pointer.
--
Ticket URL: <https://code.djangoproject.com/ticket/35293#comment:3>

Django

unread,
Mar 12, 2024, 2:46:30 PM3/12/24
to django-...@googlegroups.com
#35293: Django 5.x changes the date format on an <input type="date"> from
"2012-10-01" to "01/10/2012"
---------------------------------+--------------------------------------
Reporter: Shaheed Haque | Owner: nobody
Type: Bug | Status: closed
Component: Template system | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by Claude Paroz):

Note that Django itself has no widgets having `input type="date"` by
default. This issue may be related to some custom code. See for example an
implementation in one of my projects:
{{{
class DateInput(forms.DateInput):
input_type = 'date'

def format_value(self, value):
return str(value) if value is not None else None
}}}
See also #33113
--
Ticket URL: <https://code.djangoproject.com/ticket/35293#comment:4>
Reply all
Reply to author
Forward
0 new messages