Bokeh 1.3.4 - Problems trying to embend a widget with scritp, div in a Django page

I’ve been using bokeh plots inside Django-generated web pages with no problems, but whenever I try to add a widget, nothing happens (not even an error message). For example the following code would produce the desired result if ‘cb’ were a bokeh plot, but nothing at all with ‘cb’ as widget:

Python/Bokeh:

from bokeh.embed import components
from bokeh.models.widgets import Button
from bokeh.layouts import Row

cb=Button(label=“Teste”)
layout=Row(cb)
script,div=components(layout,CDN)

CSS:

(with links to https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.3.4.min.js inside the script tag)

Django Template:

{{ div | safe }}
{{ script | safe }}


Any help is appreciated!

There is a separate BokehJS file for widgets that is only loaded if it is explicitly requested. Are you loading that in addition to the base bokeh-min.js ?

I believe so, this one:

@carvano to investigate further a complete reproducer is really necessary. Otherwise all I can suggest is general debugging suggestions, e.g check the browser js console log or network tab.

Thanks for your answer. I could figure out the problem looking at the console log. I was loading the JS source for the widgets before the the bokeh source. Everything worked once I inverted the order.

Cheers.

1 Like