Source code for genui.utils.pagination

"""
pagination

Created by: Martin Sicho
On: 5/6/20, 10:55 AM
"""
from urllib import parse as urlparse

from django.conf import settings
from rest_framework import pagination
from rest_framework.utils.urls import replace_query_param, remove_query_param

[docs]class GenuiPagination(pagination.PageNumberPagination): page_size = 10 def __init__(self): self.location = settings.GENUI_SETTINGS['HOST_URL'] if 'HOST_URL' in settings.GENUI_SETTINGS else None
[docs] def get_url(self): uri = self.request.build_absolute_uri(location=self.location) if not self.location: query = '&'.join([f'{x}={self.request.query_params[x]}' for x in self.request.query_params]) return uri + f'?{query}' path = self.request.get_full_path() return urlparse.urljoin(uri, path)