Django 将人复数为人

Django pluralize person as people

尝试在计数大于 1 时在 Django 模板中输出正确的复数值。

<p>{{ review.markers.helpful.count }} person{{ reviews.markers.helpful.count|length|pluralize }} found this helpful</p>

仍然returns1 persons2 persons而不是1 person2 people

在模板中解决这个问题有什么帮助吗?

您可以指定两种形式的后缀:

pe{{ reviews.markers.helpful.count<strong>|pluralize:"rson,eople"</strong> }}

或更简单:

{{ reviews.markers.helpful.count<strong>|pluralize:"person,people"</strong> }}