【发布时间】:2020-05-31 09:29:41
【问题描述】:
在一个数组中,我得到如下数组:
['1','2','3','4','5','6']
在另一个数组中,我得到的数组如下:
['1','6']
在模板中我正在做这样的事情:
<div class="col-md-10">
{% if edit_data.features %}
{% for feature in edit_data.feature %}
{% for features in edit_data.features %}
{% if feature.id == features.feature_id %}
checked='checked'
{%endif%}
{%endfor%}
<input type="checkbox" name="features" value={{feature.id}} {{checked}}> {{feature.name}}
{%endfor%}
{%endif%}
</div>
在这之后我越来越喜欢:
如何选择循环上的复选框我无法在 if 条件内创建变量。我是新手请让我现在如何使复选框被选中
[1]: https://i.stack.imgur.com/LzVV4.png
在你的解决方案之后,我会变成这样:
【问题讨论】:
标签: python django django-templates django-admin