Zinnia使用MySQL后端在QuerySet.datetimes()中返回了无效值

时间:2015-03-30 13:41:14

标签: python mysql django zinnia

我已经完成了thisthis,并且在此区域内跟随了the docs,但我仍然收到了错误消息。我不知道如何调试它。追溯到最后。

更新:使用MySQL后端是罪魁祸首。 SQLite3很好,但是传递到django后端MySQL编译器代码的查询数据什么都不返回,当它自己执行时,返回一个错误。其他任何人都有这个问题,是否有解决方法,或者我的确存在错误?

重现的步骤:

使用MySQL作为数据库。

访问以下视图:

from zinnia.views.archives import EntryIndex
url(r'^testing',
        EntryIndex.as_view(),
        name='zinnia_entry_archive_index'),

输入博客。

刷新视图。

动臂。

File "/opt/envs/django16/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
  return self.dispatch(request, *args, **kwargs)
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/views/generic/base.py", line 87, in dispatch
return handler(request, *args, **kwargs)
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/views/generic/dates.py", line 333, in get
  self.date_list, self.object_list, extra_context = self.get_dated_items()
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/views/generic/dates.py", line 415, in get_dated_items
  date_list = self.get_date_list(qs, ordering='DESC')
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/views/generic/dates.py", line 394, in get_date_list
  if date_list is not None and not date_list and not allow_empty:
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/db/models/query.py", line 100, in __nonzero__
self._fetch_all()
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/db/models/query.py", line 857, in _fetch_all
  self._result_cache = list(self.iterator())
File "/opt/envs/django16/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1113, in results_iter
raise ValueError("Database returned an invalid value "

Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your database and pytz installed?

我已将此追溯到zinnia.views.archives.EntryIndex.as_view,但无法查看到底发生了什么。有人有什么想法吗?我正在运行百日草0.14.1

2 个答案:

答案 0 :(得分:1)

我已经像这样更改了mysql的时区

mysql> SET GLOBAL time_zone = '+8:00';
Query OK, 0 rows affected (0.00 sec)

mysql> SET time_zone = '+8:00';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| +08:00             | +08:00              |
+--------------------+---------------------+
1 row in set (0.00 sec)

但错误仍然存​​在。

答案 1 :(得分:0)

This link.

简而言之,您需要手动加载时区信息并解决问题。未知的时区是个问题。