Skip to content

Instantly share code, notes, and snippets.

@pjlamb12
Created January 6, 2014 19:13
Show Gist options
  • Save pjlamb12/8288056 to your computer and use it in GitHub Desktop.
Save pjlamb12/8288056 to your computer and use it in GitHub Desktop.
Django template for loop and if statement
{% for rank in ranks %}
{% if rank.person.id == person.id %}
<td>{{rank.get_rank_display}}</td>
<td>{{rank.start_date}}</td>
{% elif forloop.last %}
<td></td>
<td></td>
{% endif %}
{% endfor %}
@nas1234
Copy link

nas1234 commented Feb 2, 2019

This is brilliant, looked everywhere and found it here! BIG thanks! It works flawlessly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment