Commit cb310dc9b38611b0e1ccb5a1e850b4de4e62a544
1 parent
8a3b22d17c
Exists in
master
Added pagination. (maybe?)
Showing 1 changed file with 5 additions and 1 deletions Inline Diff
flashcards/views.py
View file @
cb310dc
from flashcards.models import Section, LecturePeriod | 1 | 1 | from flashcards.models import Section, LecturePeriod | |
from flashcards.serializers import SectionSerializer, LecturePeriodSerializer | 2 | 2 | from flashcards.serializers import SectionSerializer, LecturePeriodSerializer | |
from rest_framework.permissions import IsAuthenticatedOrReadOnly | 3 | 3 | from rest_framework.permissions import IsAuthenticatedOrReadOnly | |
from rest_framework.viewsets import ModelViewSet | 4 | 4 | from rest_framework.viewsets import ModelViewSet | |
5 | 5 | |||
6 | REST_FRAMEWORK = { | |||
7 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.CursorPagination', | |||
8 | 'PAGE_SIZE': 20 | |||
9 | } | |||
6 | 10 | |||
class SectionViewSet(ModelViewSet): | 7 | 11 | class SectionViewSet(ModelViewSet): | |
queryset = Section.objects.all() | 8 | 12 | queryset = Section.objects.all() | |
serializer_class = SectionSerializer | 9 | 13 | serializer_class = SectionSerializer | |
permission_classes = (IsAuthenticatedOrReadOnly,) | 10 | 14 | permission_classes = (IsAuthenticatedOrReadOnly,) | |
11 | 15 | |||
class LecturePeriodViewSet(ModelViewSet): | 12 | 16 | class LecturePeriodViewSet(ModelViewSet): |