您好,我有以下代码:
<select name="test1" class="form-control">
<option value=""></option>
{% for test in tests %}
<option value="{{ test.id }}">{{ test.name }}</option>
{% endfor %}
</select>
然后我想做这样的事情
{% if test.id %}
# show something but I need to know if there is sometinh in test.id
# I think the problem comes from this line, in fact I want this condition is realised if test.id is not empty else the condition is not realised.
{% endif %}
我该怎么做
看看这种方法是否有帮助
举个例子:
现在在templates/template.html中
您可以更好地查看此链接: https://www.geeksforgeeks.org/for-empty-loop-django-template-tags/
相关问题 更多 >
编程相关推荐