Reputation: 200
I moved from not using timezone to using timezone but I have a couple of questions about the handling of it. First of all my settings look like this:
TIME_ZONE = "Europe/Amsterdam"
USE_TZ = True
I now get the correct timezone back from the database but not in the right timezone. I suspect that when I have my TIME_ZONE
on Europe/Amsterdam that I get that timezone back. But instead I get:
2020-09-27 23:00:07+00:00
But what I want to receive is:
2020-09-27 22:00:00+02:00
I can do this by using
timezone.localtime(date_object)
But is there a way to get the timezone back in the right format straight from the orm?
I am using Postgres 11 and Django 3.0.1
Upvotes: 0
Views: 332
Reputation: 896
But is there a way to get the timezone back in the right format straight from the orm?
No, Django always gives the datetime
objects in UTC; see this answer. Django refers to the TIME_ZONE
when rendering templates or parsing forms, but before that, everything's in UTC unless explicitly transformed otherwise.
Upvotes: 1