Can't solve how to use layout, gridplot, ... with django standalone

I use Bokeh (not server) with Django in a class based view. I like to use the functions: layout, gridplot, … but they do not work

# Solution 1 is working
script, div = components((plot1, plot2)) # 
context['script']  = script
context['divs']  = div

# Solution 2 is NOT working
grid = gridplot([[plot1, plot2], [plot2, plot1]], plot_width=250, plot_height=250)
context['grid'] = grid


<h1>Solution 1: - working</h1>
{% for div in divs %}
    {{div | safe}}
{% endfor %}

<h1>Solution 2 - NOT working:</h1>
{{ grid | safe }}

The rendered Page:

What to do to make gridplot work? I need two plots in one row and would prefer not to use html.

You need to pass the grid to the components function to get a script and div to render it, just the same as anything else.

1 Like

Great. I read the documentation that the grid replaces the rendering provided by components, because it can be used with show(). But now everything clear and working - thank you.