[Django] #37104: Naive timestamps used in migrations should reference the same timezone

12 views
Skip to first unread message

Django

unread,
May 18, 2026, 1:19:51 AMMay 18
to django-...@googlegroups.com
#37104: Naive timestamps used in migrations should reference the same timezone
-------------------------------------+-------------------------------------
Reporter: James Beith | Type:
| Cleanup/optimization
Status: new | Component: Database
| layer (models, ORM)
Version: 6.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
-------------------------------------+-------------------------------------
When creating a migration there are two reference timestamps; one in the
filename (e.g. `0002_auto_20260518_0601.py`) and one in the source header
(e.g. `# Generated by Django 6.0.5 on 2026-05-18 05:01`).

The filename is
[https://github.com/django/django/blob/6.0.5/django/db/migrations/utils.py#L24
created here], using current local date and time (from Python's runtime
perspective), in this example `"Europe/London"`.

The source header is
[https://github.com/django/django/blob/6.0.5/django/db/migrations/writer.py#L206
created here], using UTC if `settings.USE_TZ`, otherwise current local
date and time similar to filename.

This can lead to different (naive) timestamps used in the filename and
source header. Is there any reason why they shouldn't be the same?

In terms of a fix, I think the change might be to have the filename call
the Django timezone util instead of straight to Python's now classmethod.
--
Ticket URL: <https://code.djangoproject.com/ticket/37104>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 18, 2026, 4:28:15 AMMay 18
to django-...@googlegroups.com
#37104: Naive timestamps used in migrations should reference the same timezone
--------------------------------------+------------------------------------
Reporter: James Beith | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 6.0
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):

* component: Database layer (models, ORM) => Migrations
* stage: Unreviewed => Accepted

Comment:

Thank you for the report
--
Ticket URL: <https://code.djangoproject.com/ticket/37104#comment:1>

Django

unread,
May 18, 2026, 6:05:34 AMMay 18
to django-...@googlegroups.com
#37104: Naive timestamps used in migrations should reference the same timezone
-------------------------------------+-------------------------------------
Reporter: James Beith | Owner: Vishy
Type: | Algo
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 6.0
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 Vishy Algo):

* owner: (none) => Vishy Algo
* status: new => assigned

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

Django

unread,
May 19, 2026, 12:21:27 PMMay 19
to django-...@googlegroups.com
#37104: Naive timestamps used in migrations should reference the same timezone
-------------------------------------+-------------------------------------
Reporter: James Beith | Owner: Vishy
Type: | Algo
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 6.0
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 Vishy Algo):

* has_patch: 0 => 1

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