From c4a8e6cefa5d1df8587edb71a15a260a2b8bd90a Mon Sep 17 00:00:00 2001 From: Rohan Rangray Date: Thu, 30 Apr 2015 01:13:01 -0700 Subject: [PATCH] Added pagination sections and lectureperiods --- flashcards/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flashcards/views.py b/flashcards/views.py index eff61f9..b36c999 100644 --- a/flashcards/views.py +++ b/flashcards/views.py @@ -2,13 +2,22 @@ from flashcards.models import Section, LecturePeriod from flashcards.serializers import SectionSerializer, LecturePeriodSerializer from rest_framework.permissions import IsAuthenticatedOrReadOnly from rest_framework.viewsets import ModelViewSet +from rest_framework.pagination import PageNumberPagination +from django.core.paginator import Paginator + +class StandardResultsSetPagination(PageNumberPagination): + page_size = 40 + page_size_query_param = 'page_size' + max_page_size = 1000 class SectionViewSet(ModelViewSet): queryset = Section.objects.all() serializer_class = SectionSerializer permission_classes = (IsAuthenticatedOrReadOnly,) + pagination_class = StandardResultsSetPagination class LecturePeriodViewSet(ModelViewSet): queryset = LecturePeriod.objects.all() serializer_class = LecturePeriodSerializer permission_classes = (IsAuthenticatedOrReadOnly,) + pagination_class = StandardResultsSetPagination -- 1.9.1