class CustomPagination(pagination.PageNumberPagination):
<b>view = None</b>
def paginate_queryset(self, queryset, request, view=None):
<b>self.view = view</b>
return super().paginate_queryset(queryset, request, view)
<b>def get_meta(self, data=None, **meta):
return {
'data_from_view': self.view.__class__.__name__,
'static_data': settings.ROOT_URLCONF,
'len_per_page': len(data),
'dynamic_data_on_thy_fly': meta
}</b>
def get_paginated_response(self, data, **meta):
return Response({
'links': {
'next': self.get_next_link(),
'previous': self.get_previous_link()
},
<b>'meta': self.get_meta(data, **meta),</b>
'count': self.page.paginator.count,
'results': data
})