0

I have a model which has a DateTimeField for a start date as timestamp. When I'm creating new objects of the model and store them in the PostgreSQL database the given timezone is Europe/Berlin.

I confirmed it just before calling save() and the entries have the correct offsets in the database. The timezone of the database also matches with the timezone of the objects.

But when I retrieve objects of the model over .filter() the timezone is set to UTC, so I'm losing the timezone. Of course it should be Europe/Berlin as well. Inside settings.py is also the correct timezone:

TIME_ZONE = 'Europe/Berlin' 

Can anybody help me?

Bullaface
  • 71
  • 5
  • If I set USE_TZ = False, I get the right time. So it seems like django internally converts the start date to UTC after or on retrieval – Bullaface Sep 27 '17 at 13:34

1 Answers1

0

Following post provides an answer to the question:

return datetimes in the active timezone with a django query

The answer of this post states that Django will always return UTC, so one has to normalize the date after the queries. Case closed.

Bullaface
  • 71
  • 5