I figured that for most cases you wouldn't actually care what the timezone was. 
You would either always be displaying things in a timezone relative to the 
user, or you'd use some other external information (ex. coordinates of person 
or thing attached to the datetime object) to derive a contextually appropriate 
timezone.

For cases where you do want to retain the timezone, how about allowing the 
TZ-aware DateTime field to store the TZ data to an optional secondary field? 
That field could be a regular CharField. It wouldn't be needed for any of the 
date-based sorting or filtering. There's precedent for this sort of behaviour 
with the GenericForeignKey, and I think it would be fine, especially if the 
secondary field was optional.

What do you think?

Sam

On 2011-06-28, at 9:26 AM, Stephen Burrows wrote:

> I agree that it would be nice to be able to store tz-aware datetimes -
> but if django were going to do so, it ought to store the datetimes
> with the timezone information intact, rather than converting
> everything to the project's timezone. So, if a conversion to UTC were
> to take place, there would need to be a separate field in the database
> to store the timezone.
> 
> On Jun 27, 3:12 pm, Sam Bull <osir...@gmail.com> wrote:
>> On 2011-06-02, at 12:34 AM, Stephen Burrows wrote:
>> 
>>> Django actually already adds support for some capabilities to certain
>>> database backends, if I'm not mistaken - such as cascades through GFKs
>>> on delete.
>> 
>>> In terms of time zones, could django "assume"/ensure that the datetime
>>> stored in the backend is UTC, then handle the conversion to the local
>>> timezone itself?
>> 
>> Isn't this a viable solution? It's the universal, cross-timezone-friendly 
>> datetime objects that we care about, not the timezones they were in, right?
>> 
>> - If the DB supports timezone-aware datetime fields, just pass the datetime 
>> object through as is.
>> 
>> - If the DB doesn't support timezone-aware datetime fields, convert to UTC 
>> and store the datetime as UTC
>> 
>>   - If the datetime has tz info, convert the time to UTC using that
>> 
>>   - If the datetime doesn't have tz info, convert using the default timezone 
>> specified in the settings
>> 
>> When retrieving the data from a non-timezone-aware db, convert them from UTC 
>> to the project's timezone.
>> 
>> Sam
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers" group.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-developers+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-developers?hl=en.
> 

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

Reply via email to