我正在使用ChartIt并在尝试查看 URL 上的图表时不断收到“模板不存在”。本教程正在正确遵循,但可能在某处犯了错误。我是 Django 的新手,所以任何帮助将不胜感激。在调用 def 时,加载图表的请求正在工作。
在views.py 文件中定义。
def lineChart(request):
commitData = \
DataPool(
series=
[{'options': {
'source': TestCommit.objects.all()[:200]}, 'terms': ['author', 'author_time']}])
linechart = Chart(
datasource=commitData,
series_options=
[{'options': {
'type': 'line',
'stacking': False},
'terms': {
'author_time': [
'author_time']
}}],
chart_options=
{'title': {
'text': 'YAYs'},
'xAxis': {
'title': {
'text': 'Month number'}}})
return render_to_response({'testCommits.html': linechart})
testCommits.html
<head>
<!-- code to include the highcharts and jQuery libraries goes here -->
<!-- load_charts filter takes a comma-separated list of id's where -->
<!-- the charts need to be rendered to -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://code.highcharts.com/highcharts.js" type="text/javascript"></script>
<script src="/highcharts.js" type="text/javascript"></script>
{% load chartit %}
{{ linechart|load_charts:"container" }}
</head>
<body>
<div id='container'> Chart will be rendered here </div>
</body>