{% for invitation in invitations %}
  {% if forloop.first %}
    <div class="accordion" id="invite-accordion">
  {% endif %}

  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse"
         data-parent="#invite-accordion" href="#collapse{{ forloop.counter }}">
         {% if invitation.receiver == user %}
           Invitation from <strong>{{ invitation.sender }}</strong>
         {% else %}
           Invitation to <strong>{{ invitation.receiver }}</strong>
         {% endif %}

         to join <strong>{{ invitation.team.name }}</strong>
         {% if not invitation.read %}
           <span class="label label-success pull-right">Unread</span>
         {% endif %}
      </a>
    </div>
    <div id="collapse{{ forloop.counter }}" class="accordion-body collapse">
      <div class="accordion-inner">
        <p>
          {{ invitation.message }}
        </p>
        <a href="{{ invitation.get_absolute_url }}" class="btn">View Invitation</a>
      </div>
    </div>
  </div>

  {% if forloop.last %}
    </div>
  {% endif %}

{% empty %}
  <h3><i>No invitations</h3>
{% endfor %}

{% for invitation in invitations %}
  {% if forloop.first %}
    <div class="accordion" id="invite-accordion">
  {% endif %}

  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse"
         data-parent="#invite-accordion" href="#collapse{{ forloop.counter }}">
         {% if invitation.receiver == user %}
           Invitation from <strong>{{ invitation.sender }}</strong>
         {% else %}
           Invitation to <strong>{{ invitation.receiver }}</strong>
         {% endif %}

         to join <strong>{{ invitation.team.name }}</strong>
         {% if not invitation.read %}
           <span class="label label-success pull-right">Unread</span>
         {% endif %}
      </a>
    </div>
    <div id="collapse{{ forloop.counter }}" class="accordion-body collapse">
      <div class="accordion-inner">
        <p>
          {{ invitation.message }}
        </p>
        <a href="{{ invitation.get_absolute_url }}" class="btn btn-primary">View Invitation</a>
      </div>
    </div>
  </div>

  {% if forloop.last %}
    </div>
  {% endif %}

{% empty %}
  <h3><i>No invitations</h3>
{% endfor %}

Make a button look like a button
Make a button look like a button
