变量django模板中的嵌套for循环 {dat%中j的%s} {hed%中h的百分比} {{j.h}} {%endfor%} {%endfor%}
要从模型中按object.field\u名称获取值。我尝试了{{j}.{{h}},但它没有返回值,而是返回obj1.field_name。我应该尝试的任何可能的方法。可能重复了getattribute()模板标记,它返回了AttributeError:“设置”对象没有属性“模板字符串(如果无效)”。我应该更改settings.py文件吗?如果无效,您可以用您想要的任何sting替换变量django模板中的嵌套for循环 {dat%中j的%s} {hed%中h的百分比} {{j.h}} {%endfor%} {%endfor%},django,django-templates,Django,Django Templates,要从模型中按object.field\u名称获取值。我尝试了{{j}.{{h}},但它没有返回值,而是返回obj1.field_name。我应该尝试的任何可能的方法。可能重复了getattribute()模板标记,它返回了AttributeError:“设置”对象没有属性“模板字符串(如果无效)”。我应该更改settings.py文件吗?如果无效,您可以用您想要的任何sting替换模板\u字符串。对你来说没关系多亏了你,终于成功了! <tbody> {% for j
模板\u字符串。对你来说没关系多亏了你,终于成功了!
<tbody>
{% for j in dat %}
<tr>
{%for h in hed %}
<td>{{j.h}}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>