在成功地使用Django Chartit 2构建图形(简单的折线图和Pivot图表的不同用法)之后,我尝试用来自不同模型的数据制作折线图。它失败了,我试图复制示例provided here
它也失败了,我想知道为什么,我猜测它可能与chartit2的python3迁移(我使用python3.5/django1.8/chartit0.2.2)有关,如果从chartit1文档中得到的话。也许它还没有被改编成Python3,但我不能解决这个问题。。。这是我的代码:
TypeError at /space/reports/2
unorderable types: dict() < dict()
Request Method: GET
Request URL: http://localhost:8000/space/reports/2
Django Version: 1.8.6
Exception Type: TypeError
Exception Value:
unorderable types: dict() < dict()
Exception Location: C:\Program Files (x86)\Python 3.5\lib\site->packages\chartit\charts.py in _groupby_x_axis_and_vqs, line 159
C:\Program Files (x86)\Python 3.5\lib\site-packages\django\core\handlers\base.py in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
C:\Users\Usuario1\space\reports\views.py in reports3 'text': 'Month number'}}}) ...
C:\Program Files (x86)\Python 3.5\lib\site-packages\chartit\charts.py in init self.x_axis_vqs_groups = self._groupby_x_axis_and_vqs() ...
C:\Program Files (x86)\Python 3.5\lib\site-packages\chartit\charts.py in _groupby_x_axis_and_vqs itr1 = sorted(itr1, key=sort_fn)
chartit中对应的代码\图表.py公司名称:
dss = self.datasource.series
x_axis_vqs_groups = defaultdict(dict)
sort_fn = lambda td_tk: td_tk[1].get('xAxis', 0)
so = sorted(self.series_options.items(), key=sort_fn)
x_axis_groups = groupby(so, sort_fn)
for (x_axis, itr1) in x_axis_groups:
sort_fn = lambda td_tk: dss[td_tk[1]['_x_axis_term']]['_data']
**itr1 = sorted(itr1, key=sort_fn)**
for _vqs_num, (_data, itr2) in enumerate(groupby(itr1, sort_fn)):
x_axis_vqs_groups[x_axis][_vqs_num] = _x_vqs = {}
for tk, td in itr2:
_x_vqs.setdefault(td['_x_axis_term'], []).append(tk)
return x_axis_vqs_groups
如果你能帮忙,非常感谢!在
也许亚历山大·托多罗夫的这篇文章可能有助于:
指向错误描述的链接:http://atodorov.org/blog/2016/08/05/python-2-vs-python-3-list-sort-causes-bugs/
相关问题 更多 >
编程相关推荐