Pagination¶
This module provides optimized pagination classes for Django REST Framework.
It focuses on improving query performance and providing safer defaults for API pagination.
EnhancedPaginator¶
An optimized version of Django’s Paginator to educes unnecessary database overhead when calculating total object counts.
EnhancedPageNumberPagination¶
A DRF PageNumberPagination using the optimized paginator.
Features¶
- Uses EnhancedPaginator
- 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: