I'm using PostgreSQL to store an object with a DateTimeField
.
The DateTimeField
is using auto_now_add
options.
And it is created automatically from serializer in Django Rest Framework
.
As described in Django docs, I tried to get local timezone and activate it.
from django.utils.timezone import localtime, get_current_timezone
tz = get_current_timezone()
timezone.activate(tz)
session.started_at = localtime(session.started_at)
In template index.html
, I also try to load timezone.
{% localtime on %}
Session: start time {{ item.session.started_at }}
{% endlocaltime %}
In settings.py
USE_TZ = True
TIME_ZONE = 'UTC'
I'm using GMT+7 timezone but it still shows UTC time on template.
I'm using Django development server to test.
Am I missing something?