Opened 12 years ago
Closed 12 years ago
#21600 closed Bug (invalid)
Template forloop/forloop.parentloop '.last' property failing
| Reported by: | 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'?
Note:
See TracTickets
for help on using tickets.
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 %}(orinstead ofand).