Thursday, July 29, 2010

Re: Django has incorrect time

Try changing time zones in your settings.py

For example:

TIME_ZONE = 'America/Los_Angeles'

And make sure if you're running on Windows it matches your system's
time zone. Regardless, you should see some kind of change when you do
this. If you don't perhaps the settings.py isn't loading properly.

On Jul 29, 7:33 am, Alex <alexk...@gmail.com> wrote:
> 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