Skip to content
Snippets Groups Projects
Commit 3ad0e8d9 authored by borzechof99's avatar borzechof99 :whale2:
Browse files

Merge branch 'master' into '37-add-internationalization-to-models'

# Conflicts:
#   unisportomat/unisportomat/settings.py
parents 86845553 a868600e
No related branches found
No related tags found
No related merge requests found
"""
Adds the ability paginate content provided via REST API.
Can either be given as an argument in a model
or be given globally via settings.py.
"""
from rest_framework.pagination import PageNumberPagination
class PageNumberWithPageSizePagination(PageNumberPagination):
"""
This pagination style accepts a single number page number
in the request query parameters.
SOURCE: https://github.com/bmihelac/ra-data-django-rest-framework
"""
page_size_query_param = "page_size"
......@@ -32,6 +32,8 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
"corsheaders", # CORS Headers should be as high as possible.
"rest_framework",
# "quiz.apps.QuizConfig",
"modeltranslation", # Needs to be before django.contrib.admin because Admin Panel won't work otherwise
"django.contrib.admin",
......@@ -40,12 +42,11 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"corsheaders",
"quiz",
]
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware", # CORS Middleware should be as high as possible.
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
......@@ -53,10 +54,15 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.locale.LocaleMiddleware",
]
# SOURCE: https://github.com/bmihelac/ra-data-django-rest-framework
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "quiz.pagination.PageNumberWithPageSizePagination",
"PAGE_SIZE": 10,
}
ROOT_URLCONF = "unisportomat.urls"
TEMPLATES = [
......@@ -143,7 +149,7 @@ STATIC_URL = "/static/"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
CORS_ORITIN_WHITELIST = [
CORS_ORIGIN_WHITELIST = [
"http://localhost:3000", # User Frontend
"http://localhost:4000", # Admin Frontend
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment