I am writing a template for my first django website.
I am passing a list of dictionaries to the template in a variable. I also need to pass a few other lists which h
Perhaps a better way is to use forloop.last
. Of course, this will require that you send to the template the specific level_one_flag
and level_two_flag
out of the level_one_flags and level_two_flags arrays, but I think this solution keeps a better logical separation between view and template:
First page
{% for item in data_tables %}
{% if forloop.last and level_one_flag %}
Premier League
{% endif %}
Junior league
Member count
{% if forloop.last and level_two_flag %}
Ashtano League
{% endif %}
{% endfor %}