Hi,

That is actually the expected behaviour - django.utils.timezone.now()
should always return a UTC time.

You should always communicate in the backend with UTC time - saving
everything to the database and so on - it should always be in UTC.

When you want to present a time in a template or to the user you need to do
this according to the documentation:
https://docs.djangoproject.com/en/3.0/topics/i18n/timezones/

There is a lot of information there regarding handling timezones - but
now() will always return a UTC (if timezone support is on :))

Regards,

Andréas


Den fre 8 maj 2020 kl 14:28 skrev mehrad nayeri <mehrad.nay...@gmail.com>:

> Hi,
> I'm using django 1.11.17 and I've changed TIME_ZONE in settings.py to
> 'Asia/Tehran'
> <https://www.google.com/search?q=asia%2Ftehran+time+zone&oq=&aqs=chrome.0.35i39l8.382402j0j7&sourceid=chrome&ie=UTF-8>
>  but
> django.utils.timezone.now() returns UTC time.
> How I have to fix it? Why it doesn't work? Does it work on newer release?
> Please answer
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/27fd5fd2-b6dc-4ed2-997b-3a07f061427b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/27fd5fd2-b6dc-4ed2-997b-3a07f061427b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCeqLd1azYdyn%3DhM4%3Db%3DtxcjO_aPQsXE%3DQGX67na3oJfQg%40mail.gmail.com.

Reply via email to