Timezone definition issue in Django 1.6
If you are running Django 1.6 or later, and have enabled timezone management in your settings.py using pytz, then you could experience the following MySQL issue:
ValueError: Database returned an invalid value in QuerySet.dates(). Are time zone definitions and pytz installed?
The problem is that the MySQL server doesn't have a record of the different timezones, which is used to manage the timezone aware datetime values.
The solution to solve this issue is to populate the timezone definitions in the 'mysql' table, so MySQL server will be able to load them across all databases it runs. As described on the MySQL documentation (http://dev.mysql.com/doc/refman/5.6/en/mysql-tzinfo-to-sql.html), run the following command on your linux server (I'm using Ubuntu 12):
$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
You will be prompted to enter your root password, and then MySQL will load the timezone definitions into the 'mysql' table. Please note you could have a few timezone definitions that would not load (eg: Warning: Unable to load...), but that didn't seem to cause an issue for me.
Once this is complete, you may have to restart the MySQL server to clear the cached tables:
$ service mysql restart
That did the trick for me!