标签:select 遇到 blog settings 开始 logs base global www
最近在阿里云部署 Django(1.11.x) 时,在后台发布文章后,页面返回 500 异常。
刚开始的时候,遇到这个问题一脸懵逼,不知道该如何入手。后来把 settings.py 中 Debug=True ,然后运行网站,发现显示下面的错误信息:
Database returned an invalid datetime value. Are time zone definitions for your database installed?
看到这个信息后就知道该怎么入手解决了,手动点赞!
mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set, 1 warning (0.01 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2018-01-20 01:02:00 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.00 sec)
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_TZ = False
运行网站,大功告成!
Database returned an invalid datetime value. Are time zone definitions for your database installed?
Django + Mysql 中关于时间异常返回500错误的解决
标签:select 遇到 blog settings 开始 logs base global www
原文地址:https://www.cnblogs.com/hippieZhou/p/9898216.html