I have a python code where in routes.py
I have the following render:
return render_template(
"test.html",
stockdatalist={"TATACONSUM": '{"price":"123"}'}
)
Now in my HTML, if I do:
{% set stockdata = stockdatalist['TATACONSUM'] %}
<p> {{ stockdata }} </p>
it prints:
{"price":"123"}
However, if I change it to <p> {{ stockdata.price }} </p>
, it stops working and prints blank.
I could use some help! Much appreciated.
I tried using json.dumps
and json.loads
in routes.py
as well using filters like |tojson
in HTML, but none of them worked.