擅长:python、mysql、java
<p>Django支持相等运算符。为了解决您的代码问题,我会使用:</p>
<pre><code>{% 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>
{% if firewall.to_port==22 %} <td>Ssh Service</td>
{% elif firewall.to_port==80 %} <td>Web Service</td>
{% else %} <td>Unknown Service</td>{% endif %}
</tr>
{% endfor %}
</code></pre>