{% if forloop.counter == question.correct_answer|add:0 %} In your example, {% if forloop.counter == question.correct_answer|add:0 %}, the |add:0 filter is used to ensure that question.correct_answer is treated as a number (in case it might be a string).