S
S
Sergey Ganzhela2017-11-14 17:55:09
Django
Sergey Ganzhela, 2017-11-14 17:55:09

Lost 1 hour of time when rendering a template in Django?

Good afternoon people of the forum. Faced such a problem when outputting datetime fields to a template, 1 hour of time is lost somewhere in the negative direction.

TIME_ZONE = 'Europe/Moscow'
USE_TZ = True

when outputting to a template, filters are not applied.
broadcast.start_translation
Out[7]: datetime.datetime(2017, 11, 17, 12, 0, tzinfo=<UTC>)

In [8]: broadcast.start_translation.isoformat()
Out[8]: '2017-11-17T12:00:00+00:00'

In [9]: broadcast.end_translation
Out[9]: datetime.datetime(2017, 11, 17, 13, 0, tzinfo=<UTC>)

I look through the console, the time is stored like right, it is converted to iso to work later with js datetinepicker.
The time on the server is set correctly
Current default time zone: 'Europe/Moscow'
Local time is now:      Tue Nov 14 17:19:31 MSK 2017.
Universal Time is now:  Tue Nov 14 14:19:31 UTC 2017.

after outputting to the template, it turns out the time started and the end of the broadcast shifted one hour ago :(
in general, somehow I had to shove the crutch until I fully understood the situation :(

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question