Pagination¶
This module provides a pagination class with safer defaults for Django REST Framework.
EnhancedPageNumberPagination¶
A DRF PageNumberPagination with a client controlled page size.
Features¶
- Supports dynamic page size via query parameter:
?page_size=20 - Default max page size:
100
Configuration¶
| Setting | Value | Description |
|---|---|---|
| page_size_query_param | page_size |
Allows client-controlled page size |
| max_page_size | 100 |
Prevents excessive data requests |
Usage¶
In views:
from drf_corekit.pagination import EnhancedPageNumberPagination
class MyViewSet(ModelViewSet):
pagination_class = EnhancedPageNumberPagination
Or in settings:
REST_FRAMEWORK = {
...,
"DEFAULT_PAGINATION_CLASS": "drf_corekit.pagination.EnhancedPageNumberPagination",
}
Note
EnhancedPaginator was removed. It repeated Django's own Paginator count logic and failed on plain lists and models without an id field. DRF's default paginator is used now. EnhancedPageNumberPagination keeps the same name, import path and settings.