I have a set of "promotion" requests that appear in the template. Each of these promotions also has 1 or more purposes. I want to show the dates of the first and last appointments.
While using the "first" tag. However, using the "last" tag causes:
TemplateSyntaxError exception value: Caught an exception while rendering: Negative indexing is not supported.
Here is the script template
{% for promotion in promotions%}
{% with promotion.appointment_set.all as appointments %}
{% with appointments|first as first_ap %}
{{ first_ap.date|date }}
{% endwith %}
{% with appointments|last as last_ap %}
{{ last_ap.date|date }}
{% endwith %}
{% endwith %}
{% endfor %}
What am I doing wrong here?
alj source
share