【发布时间】:2018-11-17 06:45:33
【问题描述】:
我在使用 django html 变量时遇到问题,所以我编写了以下代码。
{%for field in instance %}
<tr>
<td width="250">
{{ field.Item }}
</td>
<td>
<input type="text" value={{ field.P_640 }} >
</td>
{% endfor %}
但在视图部分我有变量,有时我会推送过滤器值。 P_640 有时是 P_630 。如何让我的模板查看第 1 列而不是查看像 {{ field.P_640 }} 这样的字段名称,因为当我按下 P_630 时它不起作用。 ?
【问题讨论】:
-
docs.djangoproject.com/en/2.0/howto/custom-template-tags 帮你在 python 中做我们的逻辑
-
在询问之前我检查了过滤器和标签,但找不到我要找的东西。
标签: django loops templates variables