-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change country endpoint to use standard pagination without count
- Loading branch information
Showing
3 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from collections import OrderedDict | ||
from typing import Any | ||
|
||
from rest_framework.pagination import LimitOffsetPagination | ||
from rest_framework.response import Response | ||
|
||
|
||
class LimitOffsetPaginationWithoutCount(LimitOffsetPagination): | ||
def get_paginated_response(self, data: dict) -> Response: | ||
return Response( | ||
OrderedDict([("next", self.get_next_link()), ("previous", self.get_previous_link()), ("results", data)]) | ||
) | ||
|
||
def get_paginated_response_schema(self, schema: Any) -> dict: | ||
response_schema = super().get_paginated_response_schema(schema) | ||
del response_schema["properties"]["count"] | ||
return response_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters