Django 1.9.2 AssertionError: database connection isn't set to UTC
I encountered this same problem, also with a server that is normally running with the UTC+2 (in my case, Europe/Oslo).
It turned out that the system zoneinfo files on my server (Centos 7) were corrupted, which became evident in pg_timezone_names
.
postgres=# select * from pg_timezone_names where name like 'UTC';
name | abbrev | utc_offset | is_dst
------+--------+------------+--------
UTC | CEST | 02:00:00 | t
(1 row)
After running yum update tzdata
to update my server's timezone files, and restarting the PostgreSQL server, the issue appears to be resolved.
postgres=# select * from pg_timezone_names where name like 'UTC';
name | abbrev | utc_offset | is_dst
------+--------+------------+--------
UTC | UTC | 00:00:00 | f
(1 row)
My guess it that I might previously have run cat /usr/share/zoneinfo/Europe/Oslo > /etc/localtime
without first removing /etc/localtime
to change the timezone on the system, effectively overwriting the zoneinfo for UTC with the zoneinfo for Europe/Oslo.