5

I've done:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

As per:

mysql> select count(*) from `mysql`.`time_zone_name`;
+----------+
| count(*) |
+----------+
|     1778 |
+----------+

And my env has pytz:

$ pip list | grep pytz
pytz (2014.2)

But I'm still getting

ValueError: Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your database and pytz installed?

What could be the cause?

Kit Sunde
  • 35,972
  • 25
  • 125
  • 179
  • Could you provide some of your Django code to help understand the situation. The model and queryset woudl be helpful. – rockingskier Apr 03 '14 at 08:55
  • Thanks for this. I had the same problem. Rebooting the server was the final step. Who would have thought? I was relying on touching the wsgi file, but the problem is not fixed without restarting the server. – MagicLAMP Jul 17 '15 at 22:55

2 Answers2

7

default-time-zone is probably not set in your my.cnf file. Try adding

default-time-zone = 'UTC'

to your /etc/mysql/my.cnf in [mysqld] section.

Zulu
  • 8,765
  • 9
  • 49
  • 56
Emma
  • 1,061
  • 9
  • 10
1

I had the same problem solved by flushing MySQL after importing time-zones.

mysql> flush tables;
Query OK, 0 rows affected (0.01 sec)
Arman Ordookhani
  • 6,031
  • 28
  • 41