数据库采用mysql,数据库编码格式已改为utf-8:
views.py:
keyworkdata = \
PivotDataPool(
series =
[{'options': {
'source': LOrder.objects.all(),
'categories': 'com_chnl_name'},
'terms': {
'num': Count('serv_id')}}
])
keyworkchart = PivotChart(
datasource = keyworkdata,
series_options =
[{'options':{
'type': 'line',
'stacking': True},
'terms': ['num']}])
return render(request, 'keywork/index.html',
{'keyworkchart':keyworkchart,
})
模板中:
{% load chartit %}
{{ keyworkchart|load_charts:"container" }}
<div id='container'> Chart will be rendered here </div>
以上都是参考官方写的,这里运行网页就报'ascii' codec can't encode characters in position 0-8: ordinal not in range(128)错误
模型里面是用的def unicode(self):,因为这里python是2.7版本,不知道咋回事了,唉!
谁用过django_chartit帮忙说下哪里出问题的了,网上资料太少了