【发布时间】:2013-12-16 13:47:25
【问题描述】:
'int' object is not iterable 我的模板出现此错误,我明白,我认为这是什么意思 - 条件:{% elif User_No_Auth_Tld > 0 %} 不能允许for() 循环遍历结果({% for NotAuthDomain in User_No_Auth_Tld %}),但我尝试了:{% elif User_No_Auth_Tld %}(没有整数条件),但仍然得到相同的错误。
我在下面做错了什么?
谢谢
{% if not User_Tld_Entered %} <!-- show ADD TLD form -->
<hr />
#form here
<br />
<h4>Verify your domain</h4>
{% elif User_No_Auth_Tld > 0 %}
<h1>display unauth domains, with auth link</h1>
{% for NotAuthDomain in User_No_Auth_Tld %}
{{ NotAuthDomain }}
{% endfor %}
{% elif User_Auth_Tld %}
#form here.
{% endif %}
对于未来可能会看到这篇文章寻求帮助的用户:
我最终将User_No_Auth_Tld 的声明更改为不对数据库记录使用.count() 方法。
【问题讨论】:
标签: python django for-loop conditional-statements