Opened 24 hours ago

Closed 20 hours ago

#36205 closed Uncategorized (duplicate)

Date format issue in Django 5.1.6

Reported by: Li,Qianqian Owned by:
Component: Internationalization Version: 5.1
Severity: Normal Keywords: Date format issue in Django 5.1.6
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In Django 5.1.6, when setting USE_L10N = False and DATETIME_FORMAT = 'Y-m-d H:i:s', the expectation is that DateTimeField in the Admin interface displays as '2024-04-15 23:33:00'. However, it displays as 'April 15, 2024, 11:33 p.m.' (default en-us format). This worked correctly in previous versions (e.g., 5.0.x or 4.x).

Steps to reproduce:

  1. Configure settings.py as follows: LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_TZ = True USE_L10N = False DATETIME_FORMAT = 'Y-m-d H:i:s'
  2. Create a model with a DateTimeField.
  3. View the field in the Admin interface; the format does not follow DATETIME_FORMAT.

Expected behavior: Displays '2024-04-15 23:33:00'.
Actual behavior: Displays 'April 15, 2024, 11:33 p.m.'.

Change History (1)

comment:1 by Sarah Boyce, 20 hours ago

Component: UncategorizedInternationalization
Resolution: duplicate
Status: newclosed

This is also the case for Django 5.0.x, as it has been the case since USE_L10N was removed in Django 5.0
I believe this is a duplicate of #35990, in that the overridden date formatting settings are ignored when USE_I18N is True.

This behavior is by design and well documented, for example https://docs.djangoproject.com/en/5.1/ref/settings/#datetime-format

Note that the locale-dictated format has higher precedence and will be applied instead.

Please start a discussion on the Django Forum if you believe this behavior should change.

Note: See TracTickets for help on using tickets.
Back to Top