如何将None替换为默认值而不替换0?

时间:2019-04-08 07:33:54

标签: html django-templates

我在HTML中有一个表格,其中列出了一些项目:它们的名称,ID和库存。但是对于某些项目,没有库存数据,在这种情况下,我要显示空白而不是空白。但是当股票价值为0时,我想显示为0。

   <tr class="highlight-black">
        <td class="round cell color">{{temp_item.num_item_OF}}</td>
        <td class="round cell color">
            <a href = "{% url 'app_rafale:item_overview' pk=temp_item.pk %}" {{temp_item.num_item}}>
                {{temp_item.num_item}}
            </a>
        </td>
        <td class="round cell color">{{temp_item.stock : default:''}}</td>
    </tr>

当库存值为0时,我期望输出为0,但实际输出为'',但是当库存值为无时,我希望保留输出''。

0 个答案:

没有答案
相关问题