diff --git a/apps/properties/pagination.py b/apps/properties/pagination.py new file mode 100644 index 0000000..17abb5f --- /dev/null +++ b/apps/properties/pagination.py @@ -0,0 +1,6 @@ +from rest_framework.pagination import PageNumberPagination + +class HomeMatchPagination(PageNumberPagination): + page_size = 20 + max_page_size = 100 + page_query_param = "page_size" diff --git a/apps/properties/views/property_views.py b/apps/properties/views/property_views.py index 9bab371..bc85a30 100644 --- a/apps/properties/views/property_views.py +++ b/apps/properties/views/property_views.py @@ -8,6 +8,7 @@ from apps.properties.serializers.property_serializers import PropertiesWriteSerializer, PropertiesReadSerializer from apps.properties.serializers.reviews_serializers import ReviewsSerializer from apps.properties.permissions import IsAdvertiser, IsReviewOwner, IsPropertyOwner +from apps.properties.pagination import HomeMatchPagination from apps.properties.repositories import PropertyRepository from apps.properties.use_cases import PropertyUseCase, ReviewUseCase @@ -18,6 +19,7 @@ class CreateListReviewPropertyView(generics.ListCreateAPIView): serializer_class = ReviewsSerializer + pagination_class = HomeMatchPagination def get_permissions(self): if self.request.method == "GET": @@ -48,6 +50,7 @@ def get_permissions(self): class CreateListPropertyView(generics.ListCreateAPIView): filterset_class = PropertiesFilters + pagination_class = HomeMatchPagination def get_queryset(self): return PropertyRepository.list_properties_with_order() diff --git a/config/settings.py b/config/settings.py index 704cd15..26149c6 100644 --- a/config/settings.py +++ b/config/settings.py @@ -104,6 +104,9 @@ "rest_framework.permissions.IsAuthenticatedOrReadOnly", ), "DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"], + "DEFAULT_PAGINATION_CLASS": "apps.properties.pagination.HomeMatchPagination", + "PAGE_SIZE": 20 + } SIMPLE_JWT = {