<table class="{{ display_type_classes }}" {{ display_type_data_attrs }}>
    <thead>
        {% for model in collection %}
        {% if forloop.first %}
        <tr>
            <th>ID</th>
            {% for field, value in model.fields.items %}
            <th>{{ field }}</th>
            {% endfor %}
            <th>Link</th>
        </tr>
       {% endif %}
    {% endfor %}
    </thead>
    <tbody>
        {% for model in collection %}
        <tr>
            <td>{{ model.pk }}</td>
            {% for field, value in model.fields.items %}
            <td>{{ value }}</td>
            {% endfor %}
            <td>
                <a href="{% url view_url model.pk %}" class="btn btn-xs btn-info">View</a>
            </td>
            {% endfor %}
        </tr>
    </tbody>
</table>

<table class="{{ display_type_classes }}" {{ display_type_data_attrs }}>
    <thead>
        {% for model in collection %}
        {% if forloop.first %}
        <tr>
            <th>ID</th>
            {% for field, value in model.fields.items %}
            <th>{{ field }}</th>
            {% endfor %}
            <th>Link</th>
        </tr>
       {% endif %}
    {% endfor %}
    </thead>
    <tbody>
        {% for model in collection %}
        <tr>
            <td>{{ model.pk }}</td>
            {% for field, value in model.fields.items %}
            <td>{{ value }}</td>
            {% endfor %}
            <td>
                <a href="{% url view_url model.pk %}" class="btn btn-xs btn-info">View</a>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>

Fix template error in loop
Fix template error in loop
