2

Django time zone support is wrong (but, I'm sure there is some thing I miss)

I SET time to America/Los_Angeles with SERVER(UBUNTU), mysql, and django too.

And the server is Oregon and I am in CA. As I know, there is no time difference.

I printed all of time with php, mysql, and django too.

all results are PST!

However, I get date from server. It's totally different. (-7 hours from the DB's date)

If turned off TZ support in settings.py, the django print exactly same date and time form DB

I searched 3 hours with no luck :(

what should I check more or change?

Thanks in advance :)

======================================================== ;UPDATE

Django assumed DB as UDT time. then force calculate to location time as -7 PDT

(HAVE TO) Insert through Django with timezone.now() Then Solved !! :)

Rohan
  • 52,392
  • 12
  • 90
  • 87
joseph
  • 181
  • 1
  • 2
  • 11

1 Answers1

0

You don't mention if you've called "activate" on your timezone yet, I suspect that might be the problem. The 7 hour from PDT offset would be GMT.

At the very least, call timezone.activate(sometz) as detailed here https://docs.djangoproject.com/en/1.5/topics/i18n/timezones/#selecting-the-current-time-zone - Making a couple test views to toggle between tzs should be enough to see if that's causing your issue. This activates it for the thread, so depending on your users use patterns for your site, you may want to call activate through middleware as described in that doc page.

Jamey Pearce
  • 133
  • 1
  • 6
  • Thank you. but, I turned on TZ = True. Manually input date into DB with sql NOW() query. When load contents using Django. it changed -7 timezone with TZ = True. with TZ = False, Django print exactly same time from the DB – joseph Oct 26 '13 at 18:04