How to pass dictionary from Jinja2 (using Python) to Javascript?
Question: How to pass dictionary from Jinja2 (using Python) to Javascript ? I have
dictionary in Python and when I render template I need to use that dictionary
with Javascript, I passed from Python

    
    
    template = JINJA_ENVIRONMENT.get_template('sm.html')
    self.response.write(template.render(values=values))
    

but how to store them in Javascript variable inside html page.


Answer: Use the `json` module to turn the Python data into JSON data; JSON is a subset
of JavaScript and does fine as a JavaScript literal:

    
    
    import json
    
    js_value = json.dumps(python_value)
    

and render the `js_value` in the template.

