1
# Django REST Framework
2 6
from rest_framework import pagination
3 6
from rest_framework.utils.urls import replace_query_param
4

5

6 6
class Pagination(pagination.PageNumberPagination):
7

8 6
    page_size_query_param = 'page_size'
9 6
    max_page_size = 100000
10

11 6
    def get_next_link(self):
12 6
        if not self.page.has_next():
13 6
            return None
14 0
        url = self.request and self.request.get_full_path() or ''
15 0
        url = url.encode('utf-8')
16 0
        page_number = self.page.next_page_number()
17 0
        return replace_query_param(url, self.page_query_param, page_number)
18

19 6
    def get_previous_link(self):
20 6
        if not self.page.has_previous():
21 6
            return None
22 0
        url = self.request and self.request.get_full_path() or ''
23 0
        url = url.encode('utf-8')
24 0
        page_number = self.page.previous_page_number()
25 0
        return replace_query_param(url, self.page_query_param, page_number)

Read our documentation on viewing source code .

Loading