From 85cd14acba7b8236ba11fafad15fdbfe62cea8b7 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 28 Feb 2012 15:22:04 +0530 Subject: [PATCH] add prev / next page --- manifests/ships/views.py | 5 +++++ manifests/templates/trans.html | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/manifests/ships/views.py b/manifests/ships/views.py index 3fd4afc..164007d 100644 --- a/manifests/ships/views.py +++ b/manifests/ships/views.py @@ -91,6 +91,7 @@ def translate(request, model, field, page_no=1): m = models.__getattribute__(model) except AttributeError: return HttpResponse("no such model") + page_no = int(page_no) response = [] if field not in m._meta.get_all_field_names(): return HttpResponse("no such field") @@ -119,6 +120,10 @@ def translate(request, model, field, page_no=1): }) context = RequestContext(request, { 'values': response, + 'has_next': results.has_next(), + 'next_page': int(page_no) + 1, + 'previous_page': int(page_no) - 1, + 'has_previous': results.has_previous(), 'page_no': page_no, 'num_pages': paginator.num_pages, 'model': model, diff --git a/manifests/templates/trans.html b/manifests/templates/trans.html index 018036e..f424fa8 100644 --- a/manifests/templates/trans.html +++ b/manifests/templates/trans.html @@ -1,6 +1,16 @@ + @@ -26,6 +36,14 @@ var trans = { {% endfor %} +
+ {% if has_previous %} + + {% endif %} + {% if has_next %} + + {% endif %} +