【发布时间】:2014-01-14 08:51:00
【问题描述】:
我正在尝试打印图表并将带有数据图表的参数返回到模板。
Views.py:
def errors(request):
totalErrors = total_errors()
table = table_errors()
return render_to_response('macaco_errores.djhtml', {'totalErrors': totalErrors, 'table': table})
没有'table'参数打印图表没有问题,但是当我加载“load_chart”时,我在模板中得到'False'。
编辑: 模板:
{% block head %}
{% load nvd3_tags %}
{% include_chart_jscss %}
{% load_chart charttype totalesData totalesContainer extra %}
{% endblock %}
{% block body %}
<div align="center">
<h1>Errors</h1>
{% include_container totalesContainer 600 1000 %}
</div>
<div align="center">
<table border="1">
<tr>
<th>Log</th>
<th>Type</th>
</tr>
{% for type,log,date in table.items %}
<tr>
<td>{{ type }}</td>
<td>{{ log }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}
【问题讨论】:
-
发布模板的来源。听起来您给 nvd3.js 提供了错误的配置,而不是 Django 方面的任何问题
-
我用模板编辑过。
-
是的。我正在使用最新的,我可以绘制图表。我的问题是我想在表格(模板内)中打印另一个变量(字典),当我从视图返回两个参数时它没有绘制。
标签: django django-templates nvd3.js