ValueError at /admin/library/questiontype/
Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your database and pytz installed?
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/admin/library/questiontype/?add_time__year=2014 |
Django Version: | 1.6.2 |
Exception Type: | ValueError |
Exception Value: | Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your database and pytz installed? |
Exception Location: | F:\Python27\lib\site-packages\django\db\models\sql\compiler.py in results_iter, line 1108 |
Python Executable: | F:\Python27\python.exe |
Python Version: | 2.7.5 |
Python Path: | ['C:\\Users\\Administrator\\Desktop\\mysiteMysql', 'F:\\Python27\\lib\\site-packages\\setuptools-3.4.4-py2.7.egg', 'F:\\Python27\\lib\\site-packages\\pip-1.5.4-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'F:\\Python27\\DLLs', 'F:\\Python27\\lib', 'F:\\Python27\\lib\\plat-win', 'F:\\Python27\\lib\\lib-tk', 'F:\\Python27', 'F:\\Python27\\lib\\site-packages'] |
Server time: | 星期五, 18 四月 2014 21:07:34 +0800 |
然后我测试过postgres,没有问题。Mysql是因为要时区不对。
在stackoverflow看到解决方法:
Looks like error caused Django's 1.6 timezone functionality changes(https://docs.djangoproject.com/en/1.6/ref/databases/#time-zone-definitions). More informative error message was recently added but only in a development version (https://code.djangoproject.com/ticket/21629).
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:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql