#24281: auto_now & auto_now_add ignore TIME_ZONE / USE_TZ settings for DateField
-------------------------------------+-------------------------------------
     Reporter:  djbug                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  timezone             |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

 In Django 1.4, with my original design, the model layer operated in the
 default time zone.

 In Django 1.6, with in-database support for time zone-aware aggregation,
 we've started moving towards making the model layer operate in the current
 time zone.

 The solution proposed in the original report is wrong. It will always
 return the date for the current datetime in UTC. The solution proposed in
 comment 2 makes more sense.

 That said, until now `DateField` was safe from timezone-related issues.
 With that change, saving an object with `auto_now` or `auto_now_add`
 during the autumn DST change will raise an exception, because the datetime
 is ambiguous, even though the date isn't ambiguous.

 My inclination would be to document the current behavior, in order to
 avoid a backwards-incompatible change, and recommend using
 [https://docs.djangoproject.com/en/1.7/ref/models/fields/#default
 Field.default] instead.

 (On a related note, we've been talking about deprecating `auto_now` and
 `auto_now_add` for years... so users could write
 `default=datetime.date.today` or something more elaborate).

--
Ticket URL: <https://code.djangoproject.com/ticket/24281#comment:5>
Django <https://code.djangoproject.com/>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.110c2b75ffe5614628e7785df8e11553%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to