Using Django templates, I am interested in embedding a Bokeh plot by using Json output.
The Json output is already prepared for querying the database. The plot needs to be displayed in a div with a specific ID.
According to the documentation, the following code function should be used to utilize the Json output in the template:
item = JSON.parse(item_text);
Bokeh.embed.embed_item(item);
I need guidance on the correct syntax for implementing this in the template:
<div id="title"></div>
<script>
function(response) { return item = JSON.parse( {{plot_json}} ); }
function(item) { Bokeh.embed.embed_item(item); }
</script>
View file:
def home(request):
plot_json = Price_Charts.objects.using('llweb').values('timeframe_1h').filter(symbol_pair='ETH')
context = {
'plot_json': plot_json
}
return render(request, "home.html", context)