我想使用djangoifequal
和else
标记来判断变量是否等于80
或{
{% if firewalls %}
<thead>
<tr>
<th>IP address</th>
<th>Function</th>
</tr>
</thead>
{% endif %}
<tbody>
{% for firewall in firewalls %}
<tr>
<td>{{ host_ip }} : {{ firewall.from_port }}</td>
{% ifequal firewall.to_port 22 %} <td>Ssh Service</td>
{% ifequal firewall.to_port 80 %} <td>Web Service</td>
{% else %} <td>Unknown Service</td>{% endifequal %}{% endelse %}
</tr>
{% endfor %}
错误是Invalid block tag: 'endelse', expected 'else' or 'endifequal'
。有人能帮我吗?谢谢!在
Django支持相等运算符。为了解决您的代码问题,我会使用:
每一个
ifequal
你都需要用endifequal
来关闭它,你错过了一个ifequal标记的替代方法是使用if标记和==接线员。弓“==”运算符的幂:
这种方法还可以节省代码处理时间,因为它不会为每个端口号计算all if条件。在
相关问题 更多 >
编程相关推荐