Loading...

django-developers@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: auto_now=True fields aren't updated on QuerySet.update() Danny Adair Mon Feb 20 14:00:17 2012

On Tue, Feb 21, 2012 at 09:29, Anssi Kääriäinen <[EMAIL PROTECTED]> wrote:
>[...]
>> This is by design. Timezones don't make sense for date or times, only for 
>> datetimes.
>
> In [15]: activate('Australia/Sydney')
> In [16]: localtime(now()).date()
> Out[16]: datetime.date(2012, 2, 21)
> In [17]: activate('Europe/Helsinki')
> In [18]: localtime(now()).date()
> Out[18]: datetime.date(2012, 2, 20)
>
> So, the date is affected by the current time zone.

You weren't handling date objects, just asking datetimes for their date.
As you said, nothing surprising here, but I don't understand how this
is "dangerous":

> DateField(auto_now=True) together with USE_TZ, some user will see
> last_edited either in the future, or in the past.

Timezone-aware that's what I would expect.
Using your above example, if I'm in Sydney saving a model instance,
the date will be 21 Feb. No timezone in it.
What else would you want to express with "auto_now" - if you have two
users in different timezones, whose date is the "authoritative" one?

Cheers,
Danny

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.