<div> {% for row in database %} <ul> {% for element in row %} <li> {% if element.active %} {{ element.description }} {% endif %} </li> {% endfor %} </ul> {% endfor %} {% for row in res %} <p>{{ row[0] }}</p> <p>{{ row[1] }}</p> <p>{{ row[2] }}</p> <p>{{ row[3] }}</p> {% endfor %} </div>