【发布时间】:2015-09-08 08:37:28
【问题描述】:
我在 Django 模板上有这个字段:
<p class="border_dotted_bottom">
{{ expert.description|slice:":300" }}
<a href="{% url 'profile' expert.username %}">{% trans "read more" %}</a>....
</p>
如果这个对象(用户)没有“描述”(文本字段),它显示“无”这个词,我需要摆脱它,也许如果他没有“描述”,那么显示一个简单文本然后“阅读更多”
到目前为止,我已经尝试过:
<p class="border_dotted_bottom">
{{ % if expert.description >= 1 %}}
{{ expert.description|slice:":300" }}
{{% else %}}
Éste usuario por el momento no tiene descripción
<a href="{% url 'profile' expert.username %}">{% trans "read more" %}</a>....
</p>
但它不起作用,我认为这只是一个错字,或者可能与我在这里使用的条件有关......
任何人都可以对此有所了解吗?
提前致谢!
【问题讨论】:
标签: python django django-templates django-template-filters