Commit c6ec352e712cc64ef35aa15f5dd3c8b19531e032
1 parent
cb310dc9b3
Exists in
master
Fixed pagination.
Showing 2 changed files with 6 additions and 6 deletions Inline Diff
flashcards/views.py
View file @
c6ec352
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 | |||
REST_FRAMEWORK = { | 6 | |||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.CursorPagination', | 7 | |||
'PAGE_SIZE': 20 | 8 | |||
} | 9 | |||
10 | ||||
class SectionViewSet(ModelViewSet): | 11 | 6 | class SectionViewSet(ModelViewSet): | |
queryset = Section.objects.all() | 12 | 7 | queryset = Section.objects.all() | |
serializer_class = SectionSerializer | 13 | 8 | serializer_class = SectionSerializer | |
permission_classes = (IsAuthenticatedOrReadOnly,) | 14 | 9 | permission_classes = (IsAuthenticatedOrReadOnly,) | |
15 | 10 | |||
class LecturePeriodViewSet(ModelViewSet): | 16 | 11 | class LecturePeriodViewSet(ModelViewSet): |
flashy/settings.py
View file @
c6ec352
""" | 1 | 1 | """ | |
Django settings for flashy project. | 2 | 2 | Django settings for flashy project. | |
3 | 3 | |||
Generated by 'django-admin startproject' using Django 1.8. | 4 | 4 | Generated by 'django-admin startproject' using Django 1.8. | |
5 | 5 | |||
For more information on this file, see | 6 | 6 | For more information on this file, see | |
https://docs.djangoproject.com/en/1.8/topics/settings/ | 7 | 7 | https://docs.djangoproject.com/en/1.8/topics/settings/ | |
8 | 8 | |||
For the full list of settings and their values, see | 9 | 9 | For the full list of settings and their values, see | |
https://docs.djangoproject.com/en/1.8/ref/settings/ | 10 | 10 | https://docs.djangoproject.com/en/1.8/ref/settings/ | |
""" | 11 | 11 | """ | |
12 | 12 | |||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | 13 | 13 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
import os | 14 | 14 | import os | |
15 | 15 | |||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 16 | 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
17 | 17 | |||
18 | 18 | |||
# Quick-start development settings - unsuitable for production | 19 | 19 | # Quick-start development settings - unsuitable for production | |
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ | 20 | 20 | # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ | |
21 | 21 | |||
# SECURITY WARNING: keep the secret key used in production secret! | 22 | 22 | # SECURITY WARNING: keep the secret key used in production secret! | |
SECRET_KEY = '8)#-j&8dghe-y&v4a%r6u#y@r86&6nfv%k$(a((r-zh$m3ct!9' | 23 | 23 | SECRET_KEY = '8)#-j&8dghe-y&v4a%r6u#y@r86&6nfv%k$(a((r-zh$m3ct!9' | |
24 | 24 | |||
# SECURITY WARNING: don't run with debug turned on in production! | 25 | 25 | # SECURITY WARNING: don't run with debug turned on in production! | |
DEBUG = True | 26 | 26 | DEBUG = True | |
27 | 27 | |||
ALLOWED_HOSTS = [] | 28 | 28 | ALLOWED_HOSTS = [] | |
29 | 29 | |||
30 | 30 | |||
# Application definition | 31 | 31 | # Application definition | |
32 | 32 | |||
INSTALLED_APPS = ( | 33 | 33 | INSTALLED_APPS = ( | |
'django.contrib.admin', | 34 | 34 | 'django.contrib.admin', | |
'django.contrib.admindocs', | 35 | 35 | 'django.contrib.admindocs', | |
'django.contrib.auth', | 36 | 36 | 'django.contrib.auth', | |
'django.contrib.contenttypes', | 37 | 37 | 'django.contrib.contenttypes', | |
'django.contrib.sessions', | 38 | 38 | 'django.contrib.sessions', | |
'django.contrib.messages', | 39 | 39 | 'django.contrib.messages', | |
'django.contrib.staticfiles', | 40 | 40 | 'django.contrib.staticfiles', | |
'rest_framework', | 41 | 41 | 'rest_framework', | |
'flashcards', | 42 | 42 | 'flashcards', | |
) | 43 | 43 | ) | |
44 | 44 | |||
45 | REST_FRAMEWORK = { | |||
46 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.CursorPagination', | |||
47 | 'PAGE_SIZE': 20 | |||
48 | } | |||
49 | ||||
MIDDLEWARE_CLASSES = ( | 45 | 50 | MIDDLEWARE_CLASSES = ( | |
'django.contrib.sessions.middleware.SessionMiddleware', | 46 | 51 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | 47 | 52 | 'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | 48 | 53 | 'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | 49 | 54 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | 50 | 55 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | 51 | 56 | 'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | 52 | 57 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
'django.middleware.security.SecurityMiddleware', | 53 | 58 | 'django.middleware.security.SecurityMiddleware', | |
) | 54 | 59 | ) | |
55 | 60 | |||
ROOT_URLCONF = 'flashy.urls' | 56 | 61 | ROOT_URLCONF = 'flashy.urls' | |
57 | 62 | |||
TEMPLATES = [ | 58 | 63 | TEMPLATES = [ | |
{ | 59 | 64 | { | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | 60 | 65 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': ['templates/'], | 61 | 66 | 'DIRS': ['templates/'], | |
'APP_DIRS': True, | 62 | 67 | 'APP_DIRS': True, | |
'OPTIONS': { | 63 | 68 | 'OPTIONS': { | |
'context_processors': [ | 64 | 69 | 'context_processors': [ | |
'django.template.context_processors.debug', | 65 | 70 | 'django.template.context_processors.debug', | |
'django.template.context_processors.request', | 66 | 71 | 'django.template.context_processors.request', | |
'django.contrib.auth.context_processors.auth', | 67 | 72 | 'django.contrib.auth.context_processors.auth', | |
'django.contrib.messages.context_processors.messages', | 68 | 73 | 'django.contrib.messages.context_processors.messages', | |
], | 69 | 74 | ], | |
}, | 70 | 75 | }, | |
}, | 71 | 76 | }, | |
] | 72 | 77 | ] | |
73 | 78 | |||
WSGI_APPLICATION = 'flashy.wsgi.application' | 74 | 79 | WSGI_APPLICATION = 'flashy.wsgi.application' | |
75 | 80 | |||
76 | 81 |