From d60f8c3cc4bd6b35f4f821fd38e24a8190f1e993 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 5 Apr 2012 23:59:34 +0200 Subject: Fix the previous/next link used in the pagination --- templates/search.html | 5 +++-- templatetags/poll_extras.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/templates/search.html b/templates/search.html index 5e8f847..36fbc1d 100644 --- a/templates/search.html +++ b/templates/search.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load poll_extras %} {% block title %}{{ app_name }}{% endblock %} @@ -21,7 +22,7 @@ diff --git a/templatetags/poll_extras.py b/templatetags/poll_extras.py index f57a4a7..86d8112 100644 --- a/templatetags/poll_extras.py +++ b/templatetags/poll_extras.py @@ -1,4 +1,5 @@ from django import template +from django.http import HttpRequest from django.utils.datastructures import SortedDict register = template.Library() @@ -29,3 +30,14 @@ def to_month(value): months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') return months[value -1] + +@register.filter(name="strip_page") +def strip_page(value): + print repr(value) + if not value: + return value + if value.endswith('/'): + output = value.rsplit('/', 2) + else: + output = value.rsplit('/', 1) + return output[0] -- cgit