skillfed

django-cursor-pagination

Cursor based pagination for Django

django-cursor-pagination v0.3.0 110.5K downloads/30d#12,458 on PyPI167
Permissive license BSD Active released

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-pagination

uv

uv add django-cursor-pagination

poetry

poetry add django-cursor-pagination

Installing 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

Development Status :: 5 - Production/StableFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

cursor pagination djangokeyset paginationdjango queryset paginationoffset-free paginationrelay-style paginationcursor-based navigationefficient django pagination
djangopaginationgraphql-relay

More Dynamic Content packages

MarkupSafe

MarkupSafe provides a text object that escapes…

permissive · top 100 on PyPI

Jinja2

Jinja2 is a templating engine that renders…

permissive · top 100 on PyPI

soupsieve

Soupsieve is a CSS selector library designed to…

permissive · top 100 on PyPI

Werkzeug

Werkzeug is a WSGI utility library providing…

permissive · top 1,000 on PyPI

Flask

Flask is a lightweight WSGI web application…

permissive · top 1,000 on PyPI

Mako

Mako compiles Python-embedded templates into…

permissive · top 1,000 on PyPI

django-chunkator

Iterates over large Django QuerySets in…

permissive · top 15,000 on PyPI

fastapi-pagination

Adds pagination support to FastAPI applications…

permissive · top 5,000 on PyPI

sqlakeyset

Implements keyset-based paging for SQLAlchemy…

permissive · top 5,000 on PyPI

django-tables2

django-tables2 generates HTML tables from…

permissive · top 5,000 on PyPI

django-admin-inline-paginator-plus

Adds pagination to Django admin inline forms,…

permissive · top 15,000 on PyPI

djangorestframework-datatables

Adds server-side Datatables support to Django…

permissive · top 15,000 on PyPI

django-admin-inline-paginator

Adds pagination controls to Django admin inline…

permissive · top 5,000 on PyPI

graphene-django-optimizer

Automatically optimizes GraphQL queries…

permissive · top 15,000 on PyPI

django-mock-queries

Mocks Django QuerySet operations in memory for…

permissive · top 15,000 on PyPI

django-datatables-view

Provides a Django view base class that handles…

permissive · top 15,000 on PyPI