呈现时捕获到TypeError:__init __()获得了意外的关键字参数'use_decimal' [英] Caught TypeError while rendering: __init__() got an unexpected keyword argument 'use_decimal'
问题描述
在运行程序时,我收到以下错误消息
While running the program i am getting the following error message
Caught TypeError while rendering: __init__() got an unexpected keyword
argument 'use_decimal'
这是我的代码 我正在使用jquery 1.6.4
Here is my code i am using jquery 1.6.4
def load_charts(chart_list=None, render_to=''):
embed_script = (
'<script type="text/javascript">\n'
'var _chartit_hco_array = %s;\n</script>\n'
'<script src="%s" type="text/javascript">\n</script>')
if chart_list is not None:
if isinstance(chart_list, (Chart, PivotChart)):
chart_list = [chart_list]
chart_list = [c.hcoptions for c in chart_list]
render_to_list = [s.strip() for s in render_to.split(',')]
for hco, render_to in izip_longest(chart_list, render_to_list):
if render_to:
hco['chart']['renderTo'] = render_to
embed_script = (embed_script % (simplejson.dumps(chart_list,
use_decimal=True),
CHART_LOADER_URL))
else:
embed_script = embed_script %((), CHART_LOADER_URL)
return mark_safe(embed_script)
推荐答案
The signature of simplejson.dumps
is (see documentation):
dumps(obj, skipkeys=False, ensure_ascii=True,
check_circular=True, allow_nan=True, cls=None)
如您所见,没有use_decimal
参数...但是您是这样称呼它的:
as you can see there is no use_decimal
parameter... yet you are calling it like this:
simplejson.dumps(chart_list, use_decimal=True)
编辑:实际上,进行了更多的挖掘工作其他文档.似乎use_decimal
参数是在simplejson库的版本中添加的……我建议您将库的版本升级到最新的可用版本!
Actually a bit more digging brought up this other documentation. It seems that the use_decimal
parameter was added somewhere along the version of simplejson library... I would suggest to upgrade you library version to the latest available one then!
这篇关于呈现时捕获到TypeError:__init __()获得了意外的关键字参数'use_decimal'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!