Py学习  »  问与答

使用django_chartit报错字符串不能解码/编码,求帮助!

673890989 • 9 年前 • 2757 次点击  

数据库采用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帮忙说下哪里出问题的了,网上资料太少了

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/1418
 
2757 次点击  
文章 [ 1 ]  |  最新文章 9 年前