summaryrefslogtreecommitdiff
path: root/app/utils
diff options
context:
space:
mode:
Diffstat (limited to 'app/utils')
-rw-r--r--app/utils/__init__.py0
-rw-r--r--app/utils/views.py18
2 files changed, 18 insertions, 0 deletions
diff --git a/app/utils/__init__.py b/app/utils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/utils/__init__.py
diff --git a/app/utils/views.py b/app/utils/views.py
new file mode 100644
index 0000000..910f9b3
--- /dev/null
+++ b/app/utils/views.py
@@ -0,0 +1,18 @@
+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/'
+ request.page = int(self.kwargs['page'])
+ return super(PaginatedListView, self).dispatch(request, *args, **kwargs)