'Serialize and paginate objects in a queryset.
Arguments:
pagination_cls (pagination.Paginator class): Django Rest Framework Paginator subclass.
queryset (QuerySet): Django queryset to serialize/paginate.
serializer_cls (serializers.Serializer class): Django Rest Framework Serializer subclass.
serializer_ctx (dict): Context dictionary to pass to the serializer
Returns: dict'

def _serialize_and_paginate(self, pagination_cls, queryset, request, serializer_cls, serializer_ctx):

    serializer_ctx['request'] = request
    paginator = pagination_cls()
    page = paginator.paginate_queryset(queryset, request)
    serializer = serializer_cls(page, context=serializer_ctx, many=True)
    return paginator.get_paginated_response(serializer.data).data
