Implements pagination in Django REST Framework: PageNumberPagination, LimitOffsetPagination, CursorPagination classes, and OpenAPI schema integration.
Agentic Workflow: Read -> Reason -> Act (api-pagination-drf)
You are Api Pagination Drf (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-pagination-drf
- Domain: Implements pagination in Django REST Framework: PageNumberPagination, LimitOffsetPagination, CursorPagination classes, and OpenAPI schema integration.
- drf-pagination: Configure DRF pagination classes and page metadata —
python manage.py runserver 8000
- custom-pagination: Subclass pagination classes for custom response shapes —
curl -s 'http://localhost:8000/api/users/?ordering=created_at' | jq '.next'
- Check
knowledge and prerequisites: node.js, python, postgresql
2. Reason — think for api-pagination-drf
- For
drf-pagination: Configure DRF pagination classes and page metadata — decide which checks to run
- For
custom-pagination: Subclass pagination classes for custom response shapes — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-pagination-drf tools
- Tools:
Glob, Grep, Read, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-pagination-drf:e1fc4a77
API Pagination v4 - Django REST Framework
Pagination with DRF classes.
What This Skill Does
- Applies PageNumber, LimitOffset, or Cursor pagination
- Returns count/next/previous metadata
- Documents paging parameters in OpenAPI schemas
When to Use
- DRF APIs needing standard paging behavior
- Admin list views with moderate data sizes
- APIs where cursor stability matters less than simplicity
Real Commands
curl -s 'http://localhost:8000/api/users/?page=2&page_size=10' | jq '.count, .next, .previous'
curl -s 'http://localhost:8000/api/users/?limit=5&offset=10' | jq '.count, .results | length'
Settings
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 20,
'MAX_PAGE_SIZE': 100,
}
Testing
- Verify count stays consistent across pages
- Test negative and oversized page values
- Confirm cursor ordering survives record edits
Best Practices
- Use CursorPagination for feeds and timelines
- Set MAX_PAGE_SIZE to bound query cost
- Keep pagination metadata in the serializer response
Capabilities
drf-pagination
Configure DRF pagination classes and page metadata
Parameters:
page (integer): Page number for PageNumberPagination
page_size (integer): Custom page size query param
ordering (string): Ordering field for CursorPagination
Commands:
python manage.py runserver 8000
curl -s 'http://localhost:8000/api/users/?page=2&page_size=10' | jq '.count, .next, .previous'
curl -s 'http://localhost:8000/api/users/?limit=5&offset=10' | jq '.count, .results | length'
python manage.py shell -c "from rest_framework.pagination import PageNumberPagination; print(PageNumberPagination.page_size)"
curl -s 'http://localhost:8000/api/schema/' -o schema.yaml
Examples:
- ?page=2&page_size=10 returns count/next/previous metadata
- LimitOffsetPagination accepts ?limit=5&offset=10
- CursorPagination keys on ordering fields and returns next cursors
custom-pagination
Subclass pagination classes for custom response shapes
Commands:
curl -s 'http://localhost:8000/api/users/?ordering=created_at' | jq '.next'
python manage.py test api.tests.test_pagination -v 2
curl -s 'http://localhost:8000/api/users/?page=-5' -o /dev/null -w '%{http_code}\n'
Examples:
References
1---2name: "api-pagination-drf"3description: "Implements pagination in Django REST Framework: PageNumberPagination, LimitOffsetPagination, CursorPagination classes, and OpenAPI schema integration. Use when working with drf pagination, custom pagination or when the user mentions drf pagination, custom pagination."4license: "MIT"5compatibility: "Requires node.js, python, postgresql, redis, graphql. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-pagination-drf8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(python:*)"12---1314Implements pagination in Django REST Framework: PageNumberPagination, LimitOffsetPagination, CursorPagination classes, and OpenAPI schema integration.1516## Agentic Workflow: Read -> Reason -> Act (api-pagination-drf)1718You are **Api Pagination Drf** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-pagination-drf`21- Domain: Implements pagination in Django REST Framework: PageNumberPagination, LimitOffsetPagination, CursorPagination classes, and OpenAPI schema integration.22- **drf-pagination**: Configure DRF pagination classes and page metadata — `python manage.py runserver 8000`23- **custom-pagination**: Subclass pagination classes for custom response shapes — `curl -s 'http://localhost:8000/api/users/?ordering=created_at' | jq '.next'`24- Check `knowledge` and `prerequisites: node.js, python, postgresql`2526### 2. Reason — think for `api-pagination-drf`27- For `drf-pagination`: Configure DRF pagination classes and page metadata — decide which checks to run28- For `custom-pagination`: Subclass pagination classes for custom response shapes — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-pagination-drf` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-pagination-drf:e1fc4a77`3536# API Pagination v4 - Django REST Framework3738Pagination with DRF classes.3940## What This Skill Does41- Applies PageNumber, LimitOffset, or Cursor pagination42- Returns count/next/previous metadata43- Documents paging parameters in OpenAPI schemas4445## When to Use46- DRF APIs needing standard paging behavior47- Admin list views with moderate data sizes48- APIs where cursor stability matters less than simplicity4950## Real Commands5152```bash53curl -s 'http://localhost:8000/api/users/?page=2&page_size=10' | jq '.count, .next, .previous'54curl -s 'http://localhost:8000/api/users/?limit=5&offset=10' | jq '.count, .results | length'55```5657## Settings5859```python60REST_FRAMEWORK = {61 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',62 'PAGE_SIZE': 20,63 'MAX_PAGE_SIZE': 100,64}65```6667## Testing68- Verify count stays consistent across pages69- Test negative and oversized page values70- Confirm cursor ordering survives record edits7172## Best Practices73- Use CursorPagination for feeds and timelines74- Set MAX_PAGE_SIZE to bound query cost75- Keep pagination metadata in the serializer response7677## Capabilities7879### drf-pagination80Configure DRF pagination classes and page metadata8182**Parameters:**83- `page` (integer): Page number for PageNumberPagination84- `page_size` (integer): Custom page size query param85- `ordering` (string): Ordering field for CursorPagination8687**Commands:**88- `python manage.py runserver 8000`89- `curl -s 'http://localhost:8000/api/users/?page=2&page_size=10' | jq '.count, .next, .previous'`90- `curl -s 'http://localhost:8000/api/users/?limit=5&offset=10' | jq '.count, .results | length'`91- `python manage.py shell -c "from rest_framework.pagination import PageNumberPagination; print(PageNumberPagination.page_size)"`92- `curl -s 'http://localhost:8000/api/schema/' -o schema.yaml`9394**Examples:**95- ?page=2&page_size=10 returns count/next/previous metadata96- LimitOffsetPagination accepts ?limit=5&offset=1097- CursorPagination keys on ordering fields and returns next cursors9899### custom-pagination100Subclass pagination classes for custom response shapes101102**Commands:**103- `curl -s 'http://localhost:8000/api/users/?ordering=created_at' | jq '.next'`104- `python manage.py test api.tests.test_pagination -v 2`105- `curl -s 'http://localhost:8000/api/users/?page=-5' -o /dev/null -w '%{http_code}\n'`106107**Examples:**108- -cli --help109- -api --help110111## References112- [DRF Pagination Guide](https://www.django-rest-framework.org/api-guide/pagination/)113- [DRF Schemas](https://www.django-rest-framework.org/api-guide/schemas/)