Tuesday, March 29, 2016

return objects with datetime field with default_timezone


I am using USE_TZ = True and TIME_ZONE = 'America/Sao_Paulo' when I save some datetime field it will save on MySQL in UTC as expected, but when I query this object and print object.date it still in UTC, I tried to set timezone.activate(timezone.get_default_timezone()) before querying but the result is the same. Convert from UTC to other timezone automatically is possible only on template using {% load tz %}? Can I get converted datetimes on querysets?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6df1523a-a1dd-4772-8a52-82259781bb46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment