diff options
-rw-r--r-- | templates/search.html | 5 | ||||
-rw-r--r-- | 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 @@ <div class="pagination"> <span class="step-links"> {% if threads.has_previous %} - <a href="{{ threads.previous_page_number }}">previous</a> + <a href="{{full_path|strip_page}}/{{ threads.previous_page_number }}">previous</a> {% endif %} <span class="current"> @@ -29,7 +30,7 @@ </span> {% if threads.has_next %} - <a href="{{ threads.next_page_number }}">next</a> + <a href="{{full_path|strip_page}}/{{ threads.next_page_number }}">next</a> {% endif %} </span> </div> 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] |