I get this error on my Ubuntu 12.04 machine with mysql 5.5 after I imported some Wordpress content to Mezzanine's blog_blogpost.
ValueError at /admin/blog/blogpost/
Database returned an invalid value in QuerySet.dates(). Are time zone definitions and pytz installed?
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/blog/blogpost/
Django Version: 1.6.1
Exception Type: ValueError
Exception Value:
Database returned an invalid value in QuerySet.dates(). Are time zone definitions and pytz installed?
Exception Location: /home/me/.mezenv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py in results_iter, line 1107
Python Executable: /home/me/.mezenv/bin/python
Python Version: 2.7.3
Python Path:
[u'/home/me',
'/home/me/sai',
'/home/me/.mezenv/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
'/home/me/.mezenv/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/home/me/.mezenv/lib/python2.7',
'/home/me/.mezenv/lib/python2.7/plat-linux2',
'/home/me/.mezenv/lib/python2.7/lib-tk',
'/home/me/.mezenv/lib/python2.7/lib-old',
'/home/me/.mezenv/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/me/.mezenv/local/lib/python2.7/site-packages']
Server time: Sat, 25 Jan 2014 13:44:11 +0100
Error during template rendering
In template /home/me/.mezenv/local/lib/python2.7/site-packages/grappelli_safe/templates/admin/change_list.html, error at line 140
I added to my local_settings.py
import pytz
from pytz import *
and also defined timezone in my.cnf [mysqld]
default-time-zone = "+01:00"
but I still get the error unitl I get the line in template:
the tag is:
140 {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
Appreciate your help to resolve it.
Looks like error caused Django's 1.6 timezone functionality changes. The docs now mention this error specifically (bug report, link to docs).
You have to load timezone tables into mysql (http://dev.mysql.com/doc/refman/5.6/en/mysql-tzinfo-to-sql.html). Try execute on your database server:
And then run "flush tables" or "flush query cache", otherwise the problem may not disappear even though you've loaded the correct timezone data:
updated by @qris
What worked for me:
1. Populate the timezone definitions in the 'mysql' table
2. Flush tables
3. Restart mysql
For anyone else passing through here with the same issue on Mavericks I was getting the error mentioned by Anton whereby I kept getting;
So I used
mysql_tzinfo_to_sql tz_file tz_name
from the MySQL docs to load the specific time zones that I wanted;And now Django isn't returning errors so I'm happy :D
Loading Time Zone for Mysql solved the problem for me. If you are on windows, follow these instructions :
Step #1: Download the package that contains the data files of pre-built time zone tables. http://dev.mysql.com/downloads/timezones.html
Step #2: Unzip the downloaded ZIP file to a folder on your Desktop.
Step #3: Stop MySQL Server.
For Xampp and Wamp use their GUI or stop the mysql service from the Task Manager.
Step #4: Open mysql subdirectory of your MySQL server's data directory.
For me it is
C:\xampp\mysql\data\mysql
Step #5: Overwrite time zone data files with the downloaded version.
Copy all 15 data files from your unzipped folder and paste into data folder for the mysql system database. Overwrite all these .frm, .MYD, and .MYI files.
Step #6: Restart MySQL server.
And the job is done :-)
source : http://www.geeksengine.com/article/populate-time-zone-data-for-mysql.html
For MacOS users I found solution here (in comment):
Because on MacOS we have error looks like this:
For Windows, take the following steps:
C:\ProgramData\MySQL\MySQL Server VERSION\data\mysql
not in
C:\Program Files\MySQL\MySQL Server VERSION\data
at least on Windows 7 as of 2014.
default-time-zone = 'UTC'
per the tips here. Then restart the service.