Total with plurality in Django template

Asked

Viewed 276 times

3

Guys I have the following code:

<div>
    <h4>{{ combination|length }} combinação{{ combination|length|pluralize }}</h4>
    <h5><b>Total:</b> {{ combination.paginator.count }} combinação{{ combination.paginator.count|pluralize }}</h5>
</div>

It returns me the number of combinations. I mean, in the plural it is making combinations. How to fix this?

1 answer

4


According to the documentation the pluralize accepts the argument in singular and plural.

<h4>
{{ combination|length }} 
combina{{ combination|length|pluralize:"ção,ções" }}
</h4>

he will show:

0 combinações
1 combinação
2 combinações
  • Thank you. Mainly for education.

  • Oops! It’s a pleasure to help. I forgot to post the link to the https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#pluralize

Browser other questions tagged

You are not signed in. Login or sign up in order to post.