From 47b534a13e42d498629bf9522225633122c563d5 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 7 Nov 2012 21:07:24 +0000 Subject: Make filtering optional, and pluggable. --- rest_framework/pagination.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'rest_framework/pagination.py') diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index c77a1005..aa54d154 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -1,4 +1,5 @@ from rest_framework import serializers +from rest_framework.templatetags.rest_framework import replace_query_param # TODO: Support URLconf kwarg-style paging @@ -16,13 +17,8 @@ class NextPageField(PageField): return None page = value.next_page_number() request = self.context.get('request') - relative_url = '?%s=%d' % (self.page_field, page) - if request: - for field, value in request.QUERY_PARAMS.iteritems(): - if field != self.page_field: - relative_url += '&%s=%s' % (field, value) - return request.build_absolute_uri(relative_url) - return relative_url + url = request and request.get_full_path() or '' + return replace_query_param(url, self.page_field, page) class PreviousPageField(PageField): @@ -34,13 +30,8 @@ class PreviousPageField(PageField): return None page = value.previous_page_number() request = self.context.get('request') - relative_url = '?%s=%d' % (self.page_field, page) - if request: - for field, value in request.QUERY_PARAMS.iteritems(): - if field != self.page_field: - relative_url += '&%s=%s' % (field, value) - return request.build_absolute_uri(relative_url) - return relative_url + url = request and request.get_full_path() or '' + return replace_query_param(url, self.page_field, page) class PaginationSerializerOptions(serializers.SerializerOptions): -- cgit v1.2.3