[Django] #37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of `Path("/usr/share/zoneinfo")`

24 views
Skip to first unread message

Django

unread,
May 19, 2026, 3:29:26 PMMay 19
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-----------------------------------------+--------------------------
Reporter: jodizzle | Owner: (none)
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+--------------------------
On my system, I receive failures in the test suite related to the setting
of `TIME_ZONE`, e.g.,
[https://github.com/django/django/blob/3e4e0db66961a48a080ff3ff91f6c0d954261366/tests/settings_tests/tests.py#L338
`test_incorrect_timezone`]. The root issue is that Django
[https://github.com/django/django/blob/3e4e0db66961a48a080ff3ff91f6c0d954261366/django/conf/__init__.py#L281
validates `TIME_ZONE` against a hardcoded "/usr/share/zoneinfo" path]
which does not exist on my system.

Thankfully, Python has standard library support for validating timezones
via the [https://docs.python.org/3/library/zoneinfo.html `zoneinfo`
module]. This module was introduced in Python 3.9, meaning all modern
Django versions should support it's use.

I've attached the patch that fixes my test failures. I can submit a PR if
this ticket is accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/37110>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 19, 2026, 3:29:42 PMMay 19
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-------------------------------+--------------------------------------
Reporter: jodizzle | Owner: (none)
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by jodizzle):

* Attachment "zoneinfo-patch.diff" added.

Django

unread,
May 19, 2026, 5:51:41 PMMay 19
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-------------------------------+--------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by jodizzle):

* owner: (none) => jodizzle

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

Django

unread,
May 19, 2026, 5:55:43 PMMay 19
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-----------------------------------+--------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Uncategorized | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by jodizzle):

* component: Uncategorized => Testing framework

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

Django

unread,
May 19, 2026, 10:27:57 PMMay 19
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-----------------------------------+--------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Bug | Status: assigned
Component: Testing framework | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by jodizzle):

* type: Uncategorized => Bug

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

Django

unread,
May 20, 2026, 11:21:25 AMMay 20
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
--------------------------------------+------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
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 Sarah Boyce):

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

Comment:

Refs #3415
Thank you for the suggestion
--
Ticket URL: <https://code.djangoproject.com/ticket/37110#comment:4>

Django

unread,
Jun 3, 2026, 11:33:15 AMJun 3
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
--------------------------------------+------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
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
--------------------------------------+------------------------------------
Comment (by Jacob Walls):

Terrific -- could you convert your patch to a GitHub pull request?
--
Ticket URL: <https://code.djangoproject.com/ticket/37110#comment:5>

Django

unread,
Jun 3, 2026, 11:50:00 AMJun 3
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
--------------------------------------+------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Cleanup/optimization | Status: assigned
Component: Testing framework | Version: dev
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
--------------------------------------+------------------------------------
Comment (by jodizzle):

Yes, sorry for the delay. I'll do so soon.
--
Ticket URL: <https://code.djangoproject.com/ticket/37110#comment:6>

Django

unread,
Jun 3, 2026, 1:39:21 PMJun 3
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
--------------------------------------+------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mike Edmunds):

* component: Testing framework => Core (Other)
* keywords: => settings

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

Django

unread,
Jun 4, 2026, 8:51:38 AMJun 4
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
--------------------------------------+------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by jodizzle):

Made a PR: https://github.com/django/django/pull/21417.
--
Ticket URL: <https://code.djangoproject.com/ticket/37110#comment:8>

Django

unread,
Jun 4, 2026, 10:05:17 AMJun 4
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-------------------------------------+-------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: settings | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

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

Django

unread,
Jun 4, 2026, 3:12:24 PMJun 4
to django-...@googlegroups.com
#37110: Use `zoneinfo` for validating `TIME_ZONE` setting instead of
`Path("/usr/share/zoneinfo")`
-------------------------------------+-------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: | Status: closed
Cleanup/optimization |
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: fixed
Keywords: settings | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"8c2d3dca633629effad17ccc98730234f740d03f" 8c2d3dca]:
{{{#!CommitTicketReference repository=""
revision="8c2d3dca633629effad17ccc98730234f740d03f"
Fixed #37110 -- Fixed time zone validation when missing zone directory.

On Unix systems that lack time zone information stored at
`/usr/share/zoneinfo`, time zones couldn't be validated.

Python's `zoneinfo` module was introduced in Python 3.9, meaning all
modern Django versions should support it's use.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37110#comment:10>
Reply all
Reply to author
Forward
0 new messages