aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/pagination.py
diff options
context:
space:
mode:
authorTom Christie2012-11-07 21:07:24 +0000
committerTom Christie2012-11-07 21:07:24 +0000
commit47b534a13e42d498629bf9522225633122c563d5 (patch)
treefc7acddb14038fc5f159c1399dac7974a76caf4b /rest_framework/pagination.py
parent9fd061a0b68f0cef6683bf195911a2cc7ff2fa06 (diff)
downloaddjango-rest-framework-47b534a13e42d498629bf9522225633122c563d5.tar.bz2
Make filtering optional, and pluggable.
Diffstat (limited to 'rest_framework/pagination.py')
-rw-r--r--rest_framework/pagination.py19
1 files changed, 5 insertions, 14 deletions
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):