Heres my take:
- Handle every time related data in UTC
- Record the user TZ in the UserProfile
- Display the user time with a |tz:user template filter

I don't have snippets right here but i think Jonathan Buchanan has a
clean and similar solution on his forum app:

http://www.jonathanbuchanan.plus.com/repos/forum/

On Nov 18, 1:16 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I'm curious how others handle the ever-annoying issue of timezones.
>
> Our Django app, running Django trunk/MySQL 5.0 on FreeBSD, has to
> handle multiple time zones. Each user has his/her own time zone set.
>
> Currently, I have middleware that sets os.environ["TZ"] to their time
> zone, followed by a call to time.tzset().
>
> Models are defined with DateTimeField defaults set to datetime.utcnow.
>
> The problem is that it doesn't seem to be working as I had hoped. Some
> datetimes display correctly, some don't, and some get inserted funny.
> I have a feeling it may be due to Django or MySQL's handling, but I'm
> not entirely sure.
>
> The only thing I think might fix this is re-casting every datetime as
> it is displayed using a custom template filter that pulls the variable
> from the environment, or using a template tag to get the TZ from the
> RequestContext, but that seems like a lot of overhead that is
> duplicating handling that seems to already be there.
>
> Any tips?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to