I've been working on creating some bokeh plots using Python Bokeh and Django. My goal is to display these bokeh plots in a row, but I encountered an issue at the following line:
script, div = components(row(sample_plot, variant_plot, sizing_mode='scale_width'))
in the code snippet below. Interestingly, when I try to render a single plot generated with this method, it works perfectly fine. The error message that I received is as follows:
I'm quite perplexed by why this problem arises only when I try to put my plots in a row.
ERROR (exception.py:118; 04-11-2021 16:56:58): Internal Server Error: /
Traceback (most recent call last):
...
Views (with example function to generate a plot)
def create_variant_barchart():
""" Create a sample tracking barchart for all sites.
args: None
returns: plot
"""
# Function implementation
class DashoardView(View):
def get(self, request, *args, **kwargs):
sample_plot = create_barchart_all_sites()
variant_plot = create_variant_barchart()
script, div = components(row(sample_plot, variant_plot, sizing_mode='scale_width'))
self.context['script'] = script
self.context['div'] = div
return render(request, self.template, self.context)
Template
<div class="row">
<div class="col mb-3">
<div id='outstanding_samples' class='card'>
<div class="card-header bg-light">
<h6><b>HODB Overview</b></h6>
</div>
<div class='container-fluid card-body'>
{{div|safe}}
{{script|safe}}
</div>
</div>
</div>
</div>