Django dialog non-UTC time dates in request

I am running Django with Postgres.

  • I want timezone-specific datetime objects to be returned from the database.
  • I want all dates in requests to be set to the user's locale, not UTC.
  • I can get dates and times in requests if set USE_TZ=True

    in the settings, but they are all in UTC.
  • If USE_TZ=False

    u set TIME_ZONE='America/New_York'

    , I can return results in the correct user locale, but dates are naive.

How can I get the time zone related data in the custom locale returned by default in my queries?

Cycling the results and setting them manually is not an option. It's too slow.

I'm not interested in Django's ability to convert dates to the user's timezone at render time, i.e. to a template or serializer. I need timezones to shift dates before being viewed for processing.

Note. I think I have read all the internet on this topic and found one SO post ( Ouput timezone dedicated to django datetime without filters ) that comes close to the same problem that I want to solve, but no solution has been provided.

+3


source to share





All Articles