I'm running Django with Postgres.
- I want timezone-aware datetime objects returned from the database.
- I want all the datetimes in querysets to be set to the user's locale, not UTC.
- I can get timezone aware dates in querysets if I set
USE_TZ=True
in settings, but they are all in UTC.- If
USE_TZ=False
and setTIME_ZONE='America/New_York'
, I can get my results back in the user's correct locale, but the dates are all naive.
How can I get timezone-aware datetimes in the user's locale returned in my querysets by default?
Looping through the results and setting them all manually is not an option. It's way too slow.
I'm not interested in Django's ability to convert the dates to the user's timezone at render time, i.e. in a template or serializer. I need the timezone shifted dates before the view for processing.
Note: I think I've read the entire Internet on this topic and found one SO post (Ouput timezone aware django datetime fields without filters) that comes close to the same problem I want to solve, but no solution was provided.