Javascript Django:Bokeh.safely不是一个函数

Javascript Django:Bokeh.safely不是一个函数,javascript,python,django,bokeh,Javascript,Python,Django,Bokeh,我试图在我的django应用程序中嵌入一个bokeh情节。我按照和上给出的说明进行操作 我在浏览器控制台上遇到以下错误,并且没有得到任何打印输出: Uncaught TypeError: Bokeh.safely is not a function at HTMLDocument.fn (localhost/:15) 我不是一个JS的家伙,但是Bokeh.safely出现在由Bokeh生成的脚本中。我已附上在结尾生成的脚本: My views.py文件: from django.shortcu

我试图在我的django应用程序中嵌入一个bokeh情节。我按照和上给出的说明进行操作

我在浏览器控制台上遇到以下错误,并且没有得到任何打印输出:

Uncaught TypeError: Bokeh.safely is not a function
at HTMLDocument.fn (localhost/:15)
我不是一个JS的家伙,但是Bokeh.safely出现在由Bokeh生成的脚本中。我已附上在结尾生成的脚本:

My views.py文件:

from django.shortcuts import render
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import components

def showGraph(request):
    arr = [1,4,9,16,25,36]
    y = [1,2,3,4,5,6]
    plot = figure()
    plot.line(arr, y)

    script, div = components(plot, CDN)

    return render(request, "data_collection/simple_chart.html", {"script": script, "div": div})
simplechart.html文件:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Bokeh example</title>
    <link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.0.min.css">
    <link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.0.min.css">
    <script src="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.0.min.js"></script>
    <script src="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.0.min.js"></script>

    {{ script | safe }}
</head>
<body>

    {{ div | safe }}


</body>
</html>

您正在
simplechart.html
模板中从CDN加载BokehJS的
0.12.0
版本,但几乎可以肯定的是,您使用的是比该版本更新的Python Bokeh库。BokehJS和(Python)Bokeh库的版本必须匹配

哦,是的,我刚刚从Bokeh网站上选择了CDN,假设它是最新的。我应该看到这个
(function(){
    var fn = function(){
            Bokeh.safely(function(){
                var docs_json = {....json.....};
                var render_items = [
                    {"docid": "27fe9292-3142-4617-b273-f9d932e47df3", "elementid": "7b2ef36e-a7d2-4a6b-88e6-186edecde6ca",
                     "modelid": "741db3b0-26ce-45c1-86b4-d95394c7331f"}];

                Bokeh.embed.embed_items(docs_json, render_items);
        });
    };
    if (document.readyState != "loading") fn();
    else document.addEventListener("DOMContentLoaded", fn);
})();