django-cursor-pagination
Cursor based pagination for Django
What it is and what it does
django-cursor-pagination provides a cursor-based pagination system for Django querysets as an alternative to traditional offset-based pagination. Instead of requesting page numbers, you navigate by passing cursor tokens that represent positions in the result set, asking for records after or before a given cursor. This approach prevents data shifts when new records are inserted and avoids expensive large-offset database queries.
The package requires that ordering fields be unique across all records—typically achieved by ordering on a timestamp and an ID. It supports both synchronous and asynchronous pagination, and handles forward and reverse navigation. The trade-off is that you cannot easily determine the total number of pages or jump to arbitrary positions in the dataset, making it best suited for infinite-scroll or feed-style interfaces rather than traditional paginated navigation.
Use it for:
- Building infinite-scroll feeds or timelines where new content is constantly added
- Implementing Relay-style pagination for API endpoints
- Paginating large datasets efficiently without expensive offset calculations
- Creating mobile-friendly APIs that fetch data incrementally as users scroll
- Ensuring consistent pagination results when database records are inserted between requests
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements cursor-based pagination for Django querysets, allowing navigation through large result sets using cursor tokens instead of page offsets.
Yes, if you need cursor-based pagination for Django. The package is production-stable, actively maintained, has no security vulnerabilities, zero dependencies, and solves a real problem for feed-style interfaces. Install it if you're building an API with infinite scroll or Relay-style pagination; skip it if you need traditional page-number navigation or total-count information.
Install
django-cursor-pagination on PyPI
pip
pip install django-cursor-paginationuv
uv add django-cursor-paginationpoetry
poetry add django-cursor-paginationInstalling django-cursor-pagination
Before you install
Low friction: no runtime dependencies, pure Python wheel distribution. Repository is active with recent commits and production-stable classification.
License in practice
BSD permissive license allows commercial use, modification, and distribution with minimal restrictions.
Quickstart
pip install django-cursor-pagination
from django_cursor_pagination import CursorPaginator
qs = Post.objects.all()
paginator = CursorPaginator(qs, ordering=('-created', '-id'))
page = paginator.page(first=10, after=cursor)
has_next = page.has_next
last_cursor = paginator.cursor(page[-1])
Ordering fields must uniquely identify objects across the entire queryset; NULL values are sorted to the end regardless of ASC/DESC direction.
Verify before relying
- Whether async support (apage method) works with all Django versions listed in classifiers
- Performance characteristics compared to offset pagination at very large dataset sizes
- Compatibility with custom database backends beyond standard PostgreSQL/MySQL
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 774 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 110,475/month — #12,458 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_cursor_pagination-0.3.0-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
django-chunkatorIterates over large Django QuerySets in…
permissive · top 15,000 on PyPI
fastapi-paginationAdds pagination support to FastAPI applications…
permissive · top 5,000 on PyPI
sqlakeysetImplements keyset-based paging for SQLAlchemy…
permissive · top 5,000 on PyPI
django-tables2django-tables2 generates HTML tables from…
permissive · top 5,000 on PyPI
django-admin-inline-paginator-plusAdds pagination to Django admin inline forms,…
permissive · top 15,000 on PyPI
djangorestframework-datatablesAdds server-side Datatables support to Django…
permissive · top 15,000 on PyPI
django-admin-inline-paginatorAdds pagination controls to Django admin inline…
permissive · top 5,000 on PyPI
graphene-django-optimizerAutomatically optimizes GraphQL queries…
permissive · top 15,000 on PyPI
django-mock-queriesMocks Django QuerySet operations in memory for…
permissive · top 15,000 on PyPI
django-datatables-viewProvides a Django view base class that handles…
permissive · top 15,000 on PyPI