File: pagination.rst

package info (click to toggle)
django-tables 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 916 kB
  • ctags: 1,223
  • sloc: python: 3,859; makefile: 120
file content (23 lines) | stat: -rw-r--r-- 714 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.. _pagination:

Pagination
==========

Pagination is easy, just call :meth:`.Table.paginate` and pass in the current
page number:

.. sourcecode:: python

    def people_listing(request):
        table = PeopleTable(Person.objects.all())
        table.paginate(page=request.GET.get('page', 1), per_page=25)
        return render(request, 'people_listing.html', {'table': table})

If you're using `.RequestConfig`, pass pagination options to the constructor:

.. sourcecode:: python

    def people_listing(request):
        table = PeopleTable(Person.objects.all())
        RequestConfig(request, paginate={'per_page': 25}).configure(table)
        return render(request, 'people_listing.html', {'table': table})