Django 在适当的上下文中显示单数和复数标题
我想在模板中相应地显示复数形式Django 在适当的上下文中显示单数和复数标题,django,Django,我想在模板中相应地显示复数形式 {% if page.paginator.count <= 1 %} <h3 style="display: inline">{{ page.paginator.count }} Comment</h3> {% else %} <h3 style="display: inline">{{ page.paginator.count }} Comments</h3> {% endif %} {%i
{% if page.paginator.count <= 1 %}
<h3 style="display: inline">{{ page.paginator.count }} Comment</h3>
{% else %}
<h3 style="display: inline">{{ page.paginator.count }} Comments</h3>
{% endif %}
{%if page.paginator.countDjango为此提供了这样一个函数。它的名称是
如果值不是1,则返回复数后缀。默认情况下,此后缀为s
<h3 style="display: inline"> Comment{{page.paginator.count|pluralize}}</h3>
countr{{ total|pluralize:"y,ies" }}.