问题
I'm trying to pass some variable to a bokeh document which renders a Jinja template.
The code is:
curdoc().template = template
curdoc().template_variables["testvar"] = "cia"
curdoc().add_root(row(p1,p2))
If I don't use variables at all in the template and don't try to access them via template_variables all works fine, but with the code above I get the error:
curdoc().template_variables["testvar"] = "cia"
AttributeError: 'Document' object has no attribute 'template_variables'
The command I use to start the application of course is:
bokeh serve --show myapp
Where do I do wrong?
Thanks, gian
回答1:
template_variables
is a relatively new feature added in 0.12.4
. You need to upgrade to a newer Bokeh version than whatever you have currently installed.
来源:https://stackoverflow.com/questions/41896337/jinja2-variables-in-bokeh