1# stack overflow url: https://stackoverflow.com/questions/35830779/django-rest-framework-apiview-pagination
2
3from rest_framework.pagination import LimitOffsetPagination
4
5class EventNewsItems(APIView, LimitOffsetPagination):
6
7 def get(self, request, pk, format=None):
8 event = Event.objects.get(pk=pk)
9 news = event.get_news_items().all()
10
11 results = self.paginate_queryset(news, request, view=self)
12 serializer = NewsItemSerializer(results, many=True)
13 return self.get_paginated_response(serializer.data)
14