I trying to create a json object and pass that object to template.render(JSONObj)
, but there is some error saying
ValueError: dictionary update sequence element #0 has length 1; 2 is required
What am I doing wrong?
You have to give that "JSONObj" object a key value. The template recieves a dictionary with objects and values to render inside it. So, try using this:
template.render(jsonobj=JSONObj)
Then, in your template, you can use this object this way:
{{jsonobj.some_key_inside_json_object}}
This jsonobj
is a name that identifies your "JSONObj" object inside the template's arguments.
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.