djangodjango-templatespluralize

Humanizing sentence when using pluralize in Django


What is the best way to define is/are in a sentence that uses the Django template pluralize filter? For example:

<p>
    Your item{{ items|length|pluralize }}
    is/are
    currently being processed and will ship soon.
</p>

Solution

  • As shown in last example of pluralize, you can try

    Your item{{ items|length|pluralize:" is,s are" }}
    currently being processed and will ship soon.