[Fixed]-Custom sql in django migration doesn't work

1👍

I found an answer to my question in PostgreSQL documentation 8.5.3. Time Zones:

The SQL command SET TIME ZONE sets the time zone for the session.

I was able to solve this by setting timezone in postgresql.conf (for me it was located in /etc/postgresql/9.5/main).

👤NST

0👍

Django sets its own timezone when you use a DateTimeField. In your settings.py, you should find this setting:

TIME_ZONE='UTC'

You can disable djangos timezone-usage by setting this to None. However, I believe that would simply convert all DateTimeField-values into values without a timezone. (didn’t try it)

I recommend using djangos TIME_ZONE setting in any case, since it ensures consistency over all databases.

Leave a comment