Thursday, July 29, 2010

Django has incorrect time

I'm having some strange behavior when using Django and Postgres. My
system time zone is EDT and when running datetime.now( ) from a
*Python* shell I get the correct time. If I run a Django shell
through manage.py it is an hour behind. I similarly have set up a
view on a web page to display the time and it is also an hour behind.
Now this is where things get tricky. I have some database fields that
default to datetime.now( ) and get updated to the same when changes
occur to the objects the fields are contained in. The database gets
the correct local time (say 10:30) but when these values are displayed
by Django on a page they are again an hour behind.

So, Django cannot present the correct value (one hour behind) to me,
but somehow the correct time gets inserted in the database, and when
directly displaying this value from the database in Django it is again
one hour behind.

It sounds like a time zone thing but I've tried setting Django to an
eastern zone and also None (to use the system TZ) but neither seemed
to make a difference. Any help here?

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment