* Added pagination
[django-tables2.git] / django_tables / templates / django_tables / table.html
index 9ecf79ac4ede8dc74e42f77370f73c60ff2ad181..c6d12c0b1c9227e356ce04d50e4aa939cec45867 100644 (file)
@@ -1,5 +1,8 @@
 {% spaceless %}
 {% load django_tables %}
+{% if table.page %}
+<div class="table-container">
+{% endif %}
 <table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
     <thead>
         <tr class="{% cycle "odd" "even" %}">
             <th class="{% spaceless %}{% if column.sortable %}sortable {% endif %}{% if ob %}{% if ob.is_descending %}desc{% else %}asc{% endif %}{% endif %}{% endspaceless %}"><a href="{% if ob %}{% set_url_param sort=ob.opposite %}{% else %}{% set_url_param sort=column.name %}{% endif %}">{{ column.header }}</a></th>
             {% endwith %}
         {% else %}
-            <th>{{ column.verbose_name }}</th>
+            <th>{{ column.header }}</th>
         {% endif %}
         {% endfor %}
         </tr>
     </thead>
     <tbody>
-        {% for row in table.rows %}
+        {% 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 %}
     </tbody>
 </table>
+{% if table.page %}
+<ul class="pagination">
+    {% if table.page.has_previous %}
+    <li class="previous"><a href="{% set_url_param page=table.page.previous_page_number %}">Previous</a>
+    {% endif %}
+    <li class="current">Page {{ table.page.number }} of {{ table.paginator.num_pages }}</li>
+    {% if table.page.has_next %}
+    <li class="next"><a href="{% set_url_param page=table.page.next_page_number %}">Next</a>
+    {% endif %}
+    </span>
+</div>
+</div>
+{% endif %}
 {% endspaceless %}