當計數大于 1 時,嘗試在 Django 模板中輸出正確的復數值。
<p>{{ review.markers.helpful.count }} person{{ reviews.markers.helpful.count|length|pluralize }} found this helpful</p>
仍然回傳1 personsor2 persons而不是1 personand2 people
在模板中解決這個問題有什么幫助嗎?
uj5u.com熱心網友回復:
您可以指定兩種形式的后綴:
pe{{ reviews.markers.helpful.count|pluralize:"rson,eople" }}
或者更簡單:
{{ reviews.markers.helpful.count|pluralize:"person,people" }}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/389600.html
標籤:Python 姜戈 django 模型 django-模板 多元化
