Opened 10 years ago

Closed 10 years ago

#21600 closed Bug (invalid)

Template forloop/forloop.parentloop '.last' property failing

Reported by: grz5@… Owned by: nobody
Component: Template system Version: 1.6
Severity: Normal Keywords: template, forloop
Cc: grz5@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

{% for questions in section %}

{% for question in questions %}

<some HTML which needs to be in this loop>
{% if not forloop.parentloop.last and not forloop.last %}

<button>Something here</button>

{% endif %}

{% endfor %}

{% endfor %}

Attempting to show an HTML element on every question except for the last question of the last section.

This fails even with the alternative: nested if's.

Could it have something to do with the scoping of 'last'?

Change History (1)

comment:1 by Baptiste Mispelon, 10 years ago

Resolution: invalid
Status: newclosed

Hi,

I think the code is working here but your conditional is wrong: you want to use {% if not forloop.parentloop.last or not forloop.last %} (or instead of and).

Note: See TracTickets for help on using tickets.
Back to Top