Tutorial :Dealing with timezones in Django


I'm trying to deal with timezone information in Django. I tried doing something like:

results = Competitor.objects.raw("SELECT official_start AT TIME ZONE 'UTC', official_finish AT TIME ZONE 'UTC' FROM competitor WHERE race_id=1")  

Thinking that this way I would know that the timezone was UTC but say I store a time in the database that is '2010-07-30 15:11:23' in UTC, in Django it will show up as '2010-07-30 10:11:23'. Any idea what is going on?


I realized that in the settings.py file there is an option: TIME_ZONE. setting this to UTC solved the problem.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »