Django 1.11.2
我有:
<div id="empty_keeper_and_form" style="display:none">
<p class='no_error'>
{{ keeper_and_form_set.empty_form.as_p }}
</p>
</div>
<div id="empty_keeper_or_form" style="display:none">
<p class='no_error'>
{{ keeper_or_form_set.empty_form.as_p }}
</p>
</div>
我想像这样使用包含模板:
{% include "operation.html" with operation='and'%}
这就是我所做的:
<div id="empty_keeper_{{ operation }}_form" style="display:none">
<p class='no_error'>
{{ keeper_and_form_set.empty_form.as_p }}
</p>
</div>
嗯,问题是我无法修改keeper_and_form_set。你能帮帮我吗?
答案 0 :(得分:0)
如果您有2个这样的实例,那么为什么要以艰难的方式尝试呢
你可以做到
{% include "operation.html" with operation= keeper_and_form_set.empty_form.as_p %}
和操作模板
<p class='no_error'>
{{ operation }}
</p>