Caught TypeError while rendering: __init__() got an unexpected keyword argument use_decimal

2024/11/17 12:43:51

While running the program i am getting the following error message

Caught TypeError while rendering: __init__() got an unexpected keyword
argument 'use_decimal'

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_toembed_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)
Answer

The signature of simplejson.dumps is (see documentation):

dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None)

as you can see there is no use_decimal parameter... yet you are calling it like this:

simplejson.dumps(chart_list, use_decimal=True)

EDIT: 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!

https://en.xdnf.cn/q/71554.html

Related Q&A

How to get chunks of elements from a queue?

I have a queue from which I need to get chunks of 10 entries and put them in a list, which is then processed further. The code below works (the "processed further" is, in the example, just pr…

Receiving commandline input while listening for connections in Python

I am trying to write a program that has clients connect to it while the server is still able to send commands to all of the clients. I am using the "Twisted" solution. How can I go about this…

Passing a parameter through AJAX URL with Django

Below is my code. n logs correctly in the console, and everything works perfectly if I manually enter the value for n into url: {% url "delete_photo" iddy=2%}. Alas, when I try to use n as a …

WARNING: toctree contains reference to nonexisting document error with Sphinx

I used the sphinx-quickstart to set everything up. I used doc/ for the documentation root location. The folder containing my package is setup as: myfolder/doc/mypackage/__init__.pymoprob.py...After the…

Removing nan from list - Python

I am trying to remove nan from a list, but it is refusing to go. I have tried both np.nan and nan.This is my code:ztt = [] for i in z:if i != nan:ztt.append(i) zttor:ztt = [] for i in z:if i != np.nan…

Safely unpacking results of str.split [duplicate]

This question already has answers here:How do I reliably split a string in Python, when it may not contain the pattern, or all n elements?(5 answers)Closed 6 years ago.Ive often been frustrated by the…

Get a structure of HTML code

Im using BeautifulSoup4 and Im curious whether is there a function which returns a structure (ordered tags) of the HTML code. Here is an example:<html> <body> <h1>Simple example</h…

max_help_position is not works in python argparse library

Hi colleagues I have the code (max_help_position is 2000):formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=2000) parser = argparse.ArgumentParser(formatter_class=formatter_cl…

Python - How to parse argv on the command line using stdin/stdout?

Im new to programming. I looked at tutorials for this, but Im just getting more confused. But what Im trying to do is use stdin and stdout to take in data, pass it through arguments and print out outpu…

Bad Request from Yelp API

Inspired by this Yelp tutorial, I created a script to search for all gyms in a given city. I tweaked the script with these updates in order to return ALL gyms, not just the first 20. You can find the g…