Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-06-08 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jacob Walls):

 * needs_better_patch:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019ea82e2a3e-f1a0b96b-04b5-435e-ba52-acf03038327a-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-04-15 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Huwaiza):

 Sure, thanks.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d923a6cb9-fc9ed0cd-ac6c-4a6c-9a65-704a9ccdba21-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-04-11 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * needs_better_patch:  1 => 0

Comment:

 In the future, please uncheck "Patch needs improvement" to return the
 ticket to the review queue.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d7c0f7fa4-4ec6bb79-4e7b-4ce2-b46c-b4dea4745a0c-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-04-10 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Huwaiza):

 Hi Jacob, all comments on the PR have been addressed, can you pease
 review, thanks.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d7b1c6d4e-4a306bc6-9e01-460c-8e78-37ab5fbce498-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-04-06 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jacob Walls):

 * needs_better_patch:  0 => 1

Comment:

 [https://github.com/django/django/pull/21064 PR]
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d64594bf9-5149510c-7fff-4ce6-81cd-5e465d10dded-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-04-06 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Huwaiza):

 * has_patch:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d644579a1-b1fcbb7c-c0d5-4109-85f1-3cb5ab448c2f-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-04-06 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  Huwaiza
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Huwaiza):

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

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d6429353b-43512115-92c7-401e-ab2b-50639a0baf6e-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-03-30 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE| Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Jacob Walls:

Old description:

> The `Trunc()` and `Extract()` database functions apply timezone
> conversions if `USE_TZ = True`. When the `tzinfo` argument is omitted,
> the timezone is inferred from `settings.TIME_ZONE`. This information is
> not captured by migrations, meaning that if `settings.TIME_ZONE` changes
> over the life of a project, then the database may never receive a
> corresponding update.
>
> {{{#!py
> from django.db import models
> from django.db.models.functions import ExtractHour, Now
>
> class Person(models.Model):
> hour = models.IntegerField(db_default=ExtractHour(Now()))
> }}}
>
> To reproduce:
> - Change `settings.TIME_ZONE` to "America/Chicago".
> - Make migrations, notice no migration generated.
> - Emulating the database-default python-side (as SQLite must do
> sometimes, see rest of linked forum post) now no longer produces the same
> value as the database.
>
> In this [https://forum.djangoproject.com/t/extract-isnt-safe-to-use-in-
> db-default-on-sqlite-if-time-zone-changes-at-some-point/44781/6 forum
> reply], there was an idea to implement `Trunc/Extract.deconstruct()` to
> deprecate omitting `tzinfo` if serialized into a migration and eventually
> make it default to `get_current_timezone()` when not provided.

New description:

 The `Trunc()` and `Extract()` database functions apply timezone
 conversions if `USE_TZ = True`. When the `tzinfo` argument is omitted, the
 timezone is inferred from `settings.TIME_ZONE`. If these functions are
 used in a `db_default` expression, this information is not captured by
 migrations, meaning that if `settings.TIME_ZONE` changes over the life of
 a project, then the database may never receive a corresponding update.

 {{{#!py
 from django.db import models
 from django.db.models.functions import ExtractHour, Now

 class Person(models.Model):
 hour = models.IntegerField(db_default=ExtractHour(Now()))
 }}}

 To reproduce:
 - Change `settings.TIME_ZONE` to "America/Chicago".
 - Make migrations, notice no migration generated.
 - Emulating the database-default python-side (as SQLite must do sometimes,
 see rest of linked forum post) now no longer produces the same value as
 the database.

 In this [https://forum.djangoproject.com/t/extract-isnt-safe-to-use-in-db-
 default-on-sqlite-if-time-zone-changes-at-some-point/44781/6 forum reply],
 there was an idea to implement `Trunc/Extract.deconstruct()` to deprecate
 omitting `tzinfo` if serialized into a migration and eventually make it
 default to `get_current_timezone()` when not provided.

--
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d4032a83e-c240864c-096c-49ca-acd1-de494ffe7e34-00%40eu-central-1.amazonses.com.


[Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-03-30 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  | Type:  Bug
   Status:  new  |Component:  Database
 |  layer (models, ORM)
  Version:  6.0  | Severity:  Normal
 Keywords:  tzinfo, TIME_ZONE| Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
 The `Trunc()` and `Extract()` database functions apply timezone
 conversions if `USE_TZ = True`. When the `tzinfo` argument is omitted, the
 timezone is inferred from `settings.TIME_ZONE`. This information is not
 captured by migrations, meaning that if `settings.TIME_ZONE` changes over
 the life of a project, then the database may never receive a corresponding
 update.

 {{{#!py
 from django.db import models
 from django.db.models.functions import ExtractHour, Now

 class Person(models.Model):
 hour = models.IntegerField(db_default=ExtractHour(Now()))
 }}}

 To reproduce:
 - Change `settings.TIME_ZONE` to "America/Chicago".
 - Make migrations, notice no migration generated.
 - Emulating the database-default python-side (as SQLite must do sometimes,
 see rest of linked forum post) now no longer produces the same value as
 the database.

 In this [https://forum.djangoproject.com/t/extract-isnt-safe-to-use-in-db-
 default-on-sqlite-if-time-zone-changes-at-some-point/44781/6 forum reply],
 there was an idea to implement `Trunc/Extract.deconstruct()` to deprecate
 omitting `tzinfo` if serialized into a migration and eventually make it
 default to `get_current_timezone()` when not provided.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d40320996-bb32588d-1055-4481-b83f-1efc8dd31f00-00%40eu-central-1.amazonses.com.


Re: [Django] #37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and TIME_ZONE != UTC creates ambiguity for migrations

2026-03-30 Thread Django
#37013: Omitting tzinfo argument to Trunc & Extract with USE_TZ = True and
TIME_ZONE != UTC creates ambiguity for migrations
-+-
 Reporter:  Jacob Walls  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  6.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  tzinfo, TIME_ZONE,   | Triage Stage:  Accepted
  Extract, Trunc |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * keywords:  tzinfo, TIME_ZONE => tzinfo, TIME_ZONE, Extract, Trunc
 * stage:  Unreviewed => Accepted

Comment:

 Thank you! The forum post was very educational.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d4035f576-4369d15e-5ac4-47fa-9d19-1e219b5fd724-00%40eu-central-1.amazonses.com.