--- id: django-cursor-pagination version: "0.3.0" license: BSD license_treatment: permissive maintenance: active --- # django-cursor-pagination — Cursor based pagination for Django License: permissive · Maintenance: active · Downloads: 110.5K/mo ## 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 above — 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 pip install django-cursor-pagination uv add django-cursor-pagination 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: unspecified - Install friction: low - Maintenance: active - Downloads: 110.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags cursor pagination django, keyset pagination, django queryset pagination, offset-free pagination, relay-style pagination, cursor-based navigation, efficient django pagination, django, pagination, graphql-relay [View on SkillFed](https://skillfed.io/packages/django-cursor-pagination) · [View on PyPI](https://pypi.org/project/django-cursor-pagination/)