#361: Some Basic Math Filters ---------------------------------+-------------------------------------- Reporter: ilikeprivacy@… | Owner: adrian Type: defect | Status: closed Component: Template system | Version: Severity: normal | Resolution: wontfix Keywords: filter math | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+--------------------------------------
Comment (by will@…): I would like to have a "subtract" filter for this use case: I want to only show the first 10 items in a list, then have a final line saying how many other items there were, E.g. "And 3 other items..." This is purely a display (template) logic, so it should be supported by the template language (same as 'add'). {{{ {% for l in list_items %} {% if forloop.counter < 10 %} <li>l </li> {% else %} {% ifequal forloop.counter 10 %} <li> And {{ list_items|length|subtract:10 }} other objects... </li> {% endifequal %} {% endif %} {% endfor %} }}} -- Ticket URL: <https://code.djangoproject.com/ticket/361#comment:20> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.