Я пытаюсь пройти учебник , чтобы показать простую диаграмму боке на странице django, но веб-страница пуста, когда загружается - диаграммы нет.
Был похожий вопрос переполнения стека, где в html-файле была указана неправильная версия bokeh - я проверил, чтобы убедиться, что это не так. Я также попытался использовать функцию рендеринга, поскольку render_to_response, видимо, устарела, но произошло то же самое.
<!DOCTYPE html>
<html lang='en'>
<head>
<link href="http://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css" rel="stylesheet" type="text/css">
<link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css" rel="stylesheet" type="text/css">
<script src="http://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
<script src="http://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js"></script>
{{ script | safe }}
<title>testing bokeh...</title>
</head>
<body>
{{ div | safe }}
</body>
</html>
from django.shortcuts import render, render_to_response
from bokeh.plotting import figure, output_file, show
from bokeh.embed import components
def bokehTutorial(request):
x, y, = [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]
#Setup graph plot
plot = figure(title = 'Line Chart', x_axis_label = 'X axis', y_axis_label = 'Y axis', plot_width = 400, plot_height = 400)
#plot line
plot.line(x, y, line_width = 2)
#store components
script, div = components(plot)
#return to django homepage with components sent as arguments which will then be displayed
return render_to_response('appName/bokehTutorial.html', {'script': script, 'div': div})
#return render(request, 'appName/bokehTutorial.html', {'script': script, 'div': div})
Я ожидаю, что веб-страница покажет линейный график. Однако при загрузке веб-страница выглядит пустой.