博客对象的管理视图列出了按日期排序的博客对象。当页面打开时(在开发服务器上),将返回此错误:
Database returned an invalid value in QuerySet.dates(). Are time zone definitions and pytz installed?
错误消息还包括:Server time: Tue, 3 Dec 2013 16:58:33 -0500
pip install pytz返回:Requirement already satisfied (use --upgrade to upgrade): pytz in /usr/lib/python2.6/site-packages/pytz-2013.8-py2.6.egg
在settings.py:TIME_ZONE = 'America/Detroit'中
在/etc/sysconfig/ CentOS中的ZONE='America/Detroit'机器上
启动开发服务器时,它显示:December 03, 2013 - 17:01:23
MySQL字段数据类型为DATETIME,包括2013-12-03 20:48:09之类的数据。
在admin.py中,我添加了
import pytz
from pytz import *但这改变不了什么。
不知道还需要检查什么--所有这些看起来都是正确的。为什么django会抱怨pytz?
谢谢!
发布于 2013-12-04 22:04:47
需要在MySQL中添加时区。
文档- dev.mysql.com/doc/refman/5.5/en/mysql-tzinfo-to-sql.html
https://stackoverflow.com/questions/20362617
复制相似问题