Skip to content

Commit 2663cf4

Browse files
authored
Merge pull request #502 from umccr/fix/django-pagination
Django pagination fix
2 parents 029a2bb + 3803640 commit 2663cf4

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

lib/workload/stateless/stacks/metadata-manager/app/pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class PaginationConstant(ABC):
9-
ROWS_PER_PAGE = "rowsPerPage"
9+
ROWS_PER_PAGE = "rows_per_page"
1010
PAGE = "page"
1111
COUNT = "count"
1212

lib/workload/stateless/stacks/metadata-manager/app/settings/base.py

+15
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"django.contrib.messages.middleware.MessageMiddleware",
4545
"django.middleware.clickjacking.XFrameOptionsMiddleware",
4646
'simple_history.middleware.HistoryRequestMiddleware',
47+
"djangorestframework_camel_case.middleware.CamelCaseMiddleWare",
4748
]
4849

4950
ROOT_URLCONF = "app.urls.base"
@@ -131,6 +132,20 @@
131132
REST_FRAMEWORK = {
132133
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
133134
"PAGE_SIZE": 10,
135+
# https://www.django-rest-framework.org/api-guide/parsers/#camelcase-json
136+
# https://github.com/vbabiy/djangorestframework-camel-case
137+
"DEFAULT_RENDERER_CLASSES": (
138+
"djangorestframework_camel_case.render.CamelCaseJSONRenderer",
139+
"djangorestframework_camel_case.render.CamelCaseBrowsableAPIRenderer",
140+
),
141+
"DEFAULT_PARSER_CLASSES": (
142+
"djangorestframework_camel_case.parser.CamelCaseFormParser",
143+
"djangorestframework_camel_case.parser.CamelCaseMultiPartParser",
144+
"djangorestframework_camel_case.parser.CamelCaseJSONParser",
145+
),
146+
"JSON_UNDERSCOREIZE": {
147+
'no_underscore_before_number': True,
148+
},
134149
}
135150

136151
CORS_ORIGIN_ALLOW_ALL = True

lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
aws-xray-sdk # intentionally leave out version, the daily release of this dep is ok
55
djangorestframework==3.15.2
6+
djangorestframework-camel-case==1.4.2
67
Django==5.1
78
django-cors-headers==4.4.0
89
django-environ==0.11.2

lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class PaginationConstant(ABC):
9-
ROWS_PER_PAGE = "rowsPerPage"
9+
ROWS_PER_PAGE = "rows_per_page"
1010
PAGE = "page"
1111
COUNT = "count"
1212

lib/workload/stateless/stacks/workflow-manager/workflow_manager/pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class PaginationConstant(ABC):
9-
ROWS_PER_PAGE = "rowsPerPage"
9+
ROWS_PER_PAGE = "rows_per_page"
1010
PAGE = "page"
1111
COUNT = "count"
1212

skel/django-api/project_name/pagination.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class PaginationConstant(ABC):
9-
ROWS_PER_PAGE = "rowsPerPage"
9+
ROWS_PER_PAGE = "rows_per_page"
1010
PAGE = "page"
1111
COUNT = "count"
1212

0 commit comments

Comments
 (0)