blob: f28a8cde44264461188962342e8672977fd998f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from django.views.generic import ListView
class PaginatedListView(ListView):
"""
handles my own pagination system
"""
context_object_name = 'object_list'
def dispatch(self, request, *args, **kwargs):
path = request.path.split('/')[1:-1]
if path[-1] == self.kwargs['page']:
path = "/".join(t for t in path[:-1])
request.page_url = "/" + path + '/%d/'
else:
request.page_url = request.path + '%d/'
print(request.page_url)
request.page = int(self.kwargs['page'])
return super(PaginatedListView, self).dispatch(request, *args, **kwargs)
|