【问题标题】:pytz and Centos and mysql - djangopytz 和 Centos 和 mysql - django
【发布时间】:2013-12-20 04:29:15
【问题描述】:

博客对象的管理视图列出了按日期排序的博客对象。当页面打开时(在开发服务器上),返回此错误:

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/clock 中的 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?

谢谢!

【问题讨论】:

标签: python mysql django centos pytz


【解决方案1】:

需要在 MySQL 中添加时区。
文档 - dev.mysql.com/doc/refman/5.5/en/mysql-tzinfo-to-sql.html

【讨论】:

    猜你喜欢
    • 2012-08-30
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 2016-08-12
    • 1970-01-01
    • 2016-08-16
    • 2011-06-22
    • 1970-01-01
    相关资源
    最近更新 更多