{% for b in group.buttons %} {% if forloop.first %} {% elif forloop.last %} {% else %} {% endif %} {% endfor %}