I cannot reproduce the same appearance of the table pagination format from the basic django-tables2
example. Here is my code
Model:
#models.py
class Person(models.Model):
name = models.CharField(verbose_name="full name", max_length=200)
Table:
# tables.py
import django_tables2 as tables
from loaddata.models import Person
class PersonTable(tables.Table):
class Meta:
model = Person
# add class="paleblue" to <table> tag
attrs = {"class": "paleblue"}
View:
#views.py
from django.shortcuts import render
from django_tables2 import RequestConfig
from loaddata.models import Person
from loaddata.tables import PersonTable
def people(request):
table = PersonTable(Person.objects.all())
RequestConfig(request, paginate={"per_page": 25}).configure(table)
return render(request, "loaddata/people.html", {"table": table})
This code produces the following table (#1
)
Whereas according to the tutorial, the table should look like this (#2
)
As seen my table (#1
) misses the current page number, but instead it shows the total number of data series (2 persons
). However if the pagination per_page
parameter in the view
is changed to 1
, i.e.
View modified:
#views.py
...
RequestConfig(request, paginate={"per_page": 1}).configure(table)
...
then my table (#3
) will show the current paging and the redundant 1 of 2 persons
.
What should I change in the code to remove from the pagination area the total number of data series (get rid of 2 persons
, 1 of 2 persons
) and force the current page numbering be present even if the table has one page (i.e. make table #1
the same as table #2
)?
I am using:
python 3.4.3
django 1.9
django_tables2 1.1.6