Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid QuerySet.dates() despite having pytz and mysql timezones

Tags:

django

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?

like image 314
Kit Sunde Avatar asked Apr 03 '14 07:04

Kit Sunde


2 Answers

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.

like image 109
Emma Avatar answered Nov 15 '22 01:11

Emma


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

mysql> flush tables;
Query OK, 0 rows affected (0.01 sec)
like image 34
Arman Ordookhani Avatar answered Nov 14 '22 23:11

Arman Ordookhani