Commit c4a8e6cefa5d1df8587edb71a15a260a2b8bd90a
1 parent
c6ec352e71
Exists in
master
Added pagination sections and lectureperiods
Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff
flashcards/views.py
View file @
c4a8e6c
... | ... | @@ -2,14 +2,23 @@ |
2 | 2 | from flashcards.serializers import SectionSerializer, LecturePeriodSerializer |
3 | 3 | from rest_framework.permissions import IsAuthenticatedOrReadOnly |
4 | 4 | from rest_framework.viewsets import ModelViewSet |
5 | +from rest_framework.pagination import PageNumberPagination | |
6 | +from django.core.paginator import Paginator | |
5 | 7 | |
8 | +class StandardResultsSetPagination(PageNumberPagination): | |
9 | + page_size = 40 | |
10 | + page_size_query_param = 'page_size' | |
11 | + max_page_size = 1000 | |
12 | + | |
6 | 13 | class SectionViewSet(ModelViewSet): |
7 | 14 | queryset = Section.objects.all() |
8 | 15 | serializer_class = SectionSerializer |
9 | 16 | permission_classes = (IsAuthenticatedOrReadOnly,) |
17 | + pagination_class = StandardResultsSetPagination | |
10 | 18 | |
11 | 19 | class LecturePeriodViewSet(ModelViewSet): |
12 | 20 | queryset = LecturePeriod.objects.all() |
13 | 21 | serializer_class = LecturePeriodSerializer |
14 | 22 | permission_classes = (IsAuthenticatedOrReadOnly,) |
23 | + pagination_class = StandardResultsSetPagination |