{% spaceless %}
{% load django_tables2 %}
{% if table.page %}
<div class="table-container">
{% endif %}
<table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
    <thead>
        <tr class="{% cycle "odd" "even" %}">
        {% for column in table.columns %}
        {% if column.sortable %}
            {% with column.order_by as ob %}
            <th class="{% spaceless %}{% if column.sortable %}sortable {% endif %}{% if ob %}{% if ob.is_descending %}desc{% else %}asc{% endif %}{% endif %}{% endspaceless %}"><a href="{% querystring table.prefixed_order_by_field=ob.opposite|default:column.name %}">{{ column.header }}</a></th>
            {% endwith %}
        {% else %}
            <th>{{ column.header }}</th>
        {% endif %}
        {% endfor %}
        </tr>
    </thead>
    <tbody>
        {% for row in table.page.object_list|default:table.rows %} {# support pagination #}
        <tr class="{% cycle "odd" "even" %}">
            {% for cell in row %}
                <td>{{ cell }}</td>
            {% endfor %}
        </tr>
        {% empty %}
        {% if table.empty_text %}
        <tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr>
        {% endif %}
        {% endfor %}
    </tbody>
</table>
{% if table.page %}
<ul class="pagination">
    {% if table.page.has_previous %}
    <li class="previous"><a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}">Previous</a></li>
    {% endif %}
    <li class="current">Page {{ table.page.number }} of {{ table.paginator.num_pages }}</li>
    {% if table.page.has_next %}
    <li class="next"><a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}">Next</a></li>
    {% endif %}
</ul>
</div>
{% endif %}
{% endspaceless %}
