Reputation: 488
I want to show user timezone on my django application. The database is on postgresql server. With the configuration below can not reach my goal.
Django side:
TIME_ZONE = 'UTC'
USE_L10N = True
USE_TZ = True
This is my date field:
created = models.DateTimeField(auto_now =True)
Postgres side: In my database, the field "created" seems to be aware of timezone:
\d my_table;
Column | Type
created | timestamp with time zone
Here is a sample of data stored in this field. it stores the user's timezone and not the UTC:
select created from my_table;
created
-------------------------------
2019-02-03 10:05:40.462164+02
Additionnel info:
- pytz is installed.
- my django app shows the UTC time.
My question: How can I show the timezone to the user? Do you see that there is something wrong with my configuration?
Thanks a lot in advance.
Upvotes: 0
Views: 792
Reputation: 1167
You need change Postgresql timezone to UTC
.
command:
ALTER USER User_Name SET TimeZone TO 'utc';
And restart the postgres service:
sudo service postgresql restart
Upvotes: 2