我有django bokeh项目,正在尝试添加dateRangePicker滑块,但在控制台中出现错误
bokeh-0.12.16.min.js:1 Uncaught Error: Model 'DateRangeSlider' does not exist. This could be due to a widget
or a custom model not being registered before first usage.
这是代码。
date_range_slider = DateRangeSlider(title="Date Range: ", start='2018-01-02', end='2018-06-09',
value=('2018-06-02', '2018-06-09'), step=1)
# l = layout(children=[[date_range_slider]], sizing_mode='fixed')
l = layout(children=[[p], [date_range_slider]], sizing_mode='fixed')
script, div = components(l)
print(div)
return render(request, 'index.html', {"the_script": script, "the_div": div})
我需要在Django模型中添加任何内容吗?
答案 0 :(得分:1)
BokehJS分为多个部分,以便不需要的用户(例如小部件,不必为其加载额外的JS和CSS。如果您使用小部件和components
,则需要将它们的额外JS和CSS明确包含为described in the documentation
<link
href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-x.y.z.min.css"
rel="stylesheet" type="text/css">
<script src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-x.y.z.min.js"></script>