mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Make query filters work with pagination.
This commit is contained in:
parent
e295f616ec
commit
6fbd411254
|
@ -14,6 +14,9 @@ class NextPageField(serializers.Field):
|
|||
request = self.context.get('request')
|
||||
relative_url = '?page=%d' % page
|
||||
if request:
|
||||
for field, value in request.QUERY_PARAMS.iteritems():
|
||||
if field != 'page':
|
||||
relative_url += '&%s=%s' % (field, value)
|
||||
return request.build_absolute_uri(relative_url)
|
||||
return relative_url
|
||||
|
||||
|
@ -29,7 +32,10 @@ class PreviousPageField(serializers.Field):
|
|||
request = self.context.get('request')
|
||||
relative_url = '?page=%d' % page
|
||||
if request:
|
||||
return request.build_absolute_uri('?page=%d' % page)
|
||||
for field, value in request.QUERY_PARAMS.iteritems():
|
||||
if field != 'page':
|
||||
relative_url += '&%s=%s' % (field, value)
|
||||
return request.build_absolute_uri(relative_url)
|
||||
return relative_url
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user