[Django] #36145: FIRST_DAY_OF_WEEK setting not changing the Admin calendar widget

8 views
Skip to first unread message

Django

unread,
Jan 27, 2025, 4:43:15 AMJan 27
to django-...@googlegroups.com
#36145: FIRST_DAY_OF_WEEK setting not changing the Admin calendar widget
-----------------------------+-----------------------------------------
Reporter: Phil Gyford | Type: Bug
Status: new | Component: contrib.admin
Version: 5.1 | 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
-----------------------------+-----------------------------------------
The docs for the `FIRST_DAY_OF_WEEK` setting
(https://docs.djangoproject.com/en/5.1/ref/settings/#first-day-of-week )
say:

A number representing the first day of the week. This is especially
useful when displaying a calendar. This value is only used when not using
format internationalization, or when a format cannot be found for the
current locale.

But if I set mine to `FIRST_DAY_OF_WEEK = 1` (Monday) then the calendar
widgets in Admin still start on the default, Sunday.

I've tried with `USE_I18N` set to both `True` and `False`, with no change.

I posted this query in the Django Forum but we were stumped as to whether
the documentation or the code was wrong in some way
https://forum.djangoproject.com/t/django-admin-date-pickers-ignoring-
first-day-of-week/38170/2
--
Ticket URL: <https://code.djangoproject.com/ticket/36145>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 27, 2025, 12:03:56 PMJan 27
to django-...@googlegroups.com
#36145: FIRST_DAY_OF_WEEK setting not changing the Admin calendar widget
-------------------------------+------------------------------------
Reporter: Phil Gyford | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: 5.1
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 Sarah Boyce):

* cc: Claude Paroz, Carlton Gibson (added)
* stage: Unreviewed => Accepted

Comment:

Thank you for the ticket!

It appears that it used to be possible to update `FIRST_DAY_OF_WEEK` to
update the admin date picker (used in
`django/contrib/admin/static/admin/js/calendar.js`), and now this is much
harder.

I don't think this is by design, and I think it's fair to say this is an
unintended consequence/bug from #32873 (note that we tried to improve the
docs in #35306).

It's possible a wider discussion might be needed in general for these
settings (see also #35990).
--
Ticket URL: <https://code.djangoproject.com/ticket/36145#comment:1>

Django

unread,
Jan 28, 2025, 7:00:11 AMJan 28
to django-...@googlegroups.com
#36145: FIRST_DAY_OF_WEEK setting not changing the Admin calendar widget
-------------------------------+------------------------------------
Reporter: Phil Gyford | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: 5.1
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 Carlton Gibson):

> It appears that it used to be possible to update FIRST_DAY_OF_WEEK to
update the admin date picker (used in
django/contrib/admin/static/admin/js/calendar.js), and now this is much
harder.

I'd need to dig in to see exactly why this is failing but it looks like
this should still work... `calendar.js` both fetches and uses
`FIRST_DAY_OF_WEEK`, and there are some tests (at least) in `test_i18n.py`
that suggest it's still getting to the page. (Current status: 🤔)
--
Ticket URL: <https://code.djangoproject.com/ticket/36145#comment:2>

Django

unread,
Feb 6, 2025, 3:30:48 PMFeb 6
to django-...@googlegroups.com
#36145: FIRST_DAY_OF_WEEK setting not changing the Admin calendar widget
-------------------------------+------------------------------------
Reporter: Phil Gyford | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: 5.1
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 Ryan Heo):

{{{
"""
The active locale's formats take precedence over the default
settings
even if they would be interpreted as False in a conditional test
(e.g. 0 or empty string) (#16938).
"""
}}}

I found the test code for the 'FIRST_DAY_OF_WEEK' attribute in
tests>i18n>tests.py line 697.
It says that locale's formats take precedence over the default settings.
When I checked with several locale's formats files, I found that some of
them have the 'FIRST_DAY_OF_WEEK' attribute while others don't have it.
Since the locale's formats take precedence, you can't change the
'FIRST_DAY_OF_WEEK' attribute if the locale's file has it.
If it doesn't have the attribute, such as LANGUAGE_CODE = 'ko,' you can
simply change it in the settings.py.

Now I have found a bug. On the documentation, it says the following.
**FIRST_DAY_OF_WEEK**
A number representing the first day of the week. This is especially
useful when displaying a calendar. This value is only used when not using
format internationalization, or when a format cannot be found for the
current locale.

When I used USE_I18N=False, I couldn't use the FIRST_DAY_OF_WEEK as I
wanted.
I think this is because 'USE_L10N' was removed from v5.0 but is still used
in the 'get_format' function in django>utils>formats.py rather than
use_i18n.
I will keep working on this issue to remove the use_l10n part from the
get_format and follow the current documentation.
--
Ticket URL: <https://code.djangoproject.com/ticket/36145#comment:3>

Django

unread,
Feb 6, 2025, 3:40:05 PMFeb 6
to django-...@googlegroups.com
#36145: FIRST_DAY_OF_WEEK setting not changing the Admin calendar widget
-------------------------------+------------------------------------
Reporter: Phil Gyford | Owner: Ryan Heo
Type: Bug | Status: assigned
Component: contrib.admin | Version: 5.1
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 Ryan Heo):

* cc: Ryan Heo (added)
* owner: (none) => Ryan Heo
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36145#comment:4>
Reply all
Reply to author
Forward
0 new messages