{"id":21144,"library":"django-cursor-pagination","title":"django-cursor-pagination","description":"Cursor-based pagination for Django models, providing efficient and stable pagination for large datasets. Current version: 0.3.0. Released sporadically, last update in 2024.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/photocrowd/django-cursor-pagination","tags":["django","pagination","cursor","rest-framework"],"install":[{"cmd":"pip install django-cursor-pagination","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Module name is 'cursor_pagination', not 'django_cursor_pagination'.","wrong":"from django_cursor_pagination import CursorPagination","symbol":"CursorPagination","correct":"from cursor_pagination import CursorPagination"},{"note":"Settings import, used to override default page size.","symbol":"CURSOR_PAGINATION_PAGE_SIZE","correct":"from cursor_pagination import CURSOR_PAGINATION_PAGE_SIZE"}],"quickstart":{"code":"from cursor_pagination import CursorPagination\n\nclass MyPagination(CursorPagination):\n    ordering = '-created'  # or use 'created' for ASC\n    page_size = 20\n\n# Then in your view:\n# from rest_framework.generics import ListAPIView\n# class MyListView(ListAPIView):\n#     queryset = MyModel.objects.all()\n#     pagination_class = MyPagination","lang":"python","description":"Create a custom pagination class and use it in a Django REST Framework view. Cursor pagination provides stable, efficient pagination for large datasets."},"warnings":[{"fix":"Use a field like '-created' or 'id' that is unique in practice. Avoid fields with many duplicates.","message":"The 'ordering' field must be a unique or nearly unique field (e.g., primary key, created timestamp with timezone). Non-unique ordering can cause missing or duplicate results.","severity":"gotcha","affected_versions":"all"},{"fix":"Use cursor-based links from response instead of manual page numbers.","message":"Cursor pagination does not support arbitrary page numbers. It only provides 'next' and 'previous' cursors. Do not expect page query parameter like '?page=3'.","severity":"gotcha","affected_versions":"all"},{"fix":"Test with async views if applicable. The change is backward-compatible for sync usage.","message":"Version 0.3.0 added async queryset evaluation support. If you upgrade from <0.3.0, ensure your code doesn't rely on synchronous-only behavior.","severity":"breaking","affected_versions":"<0.3.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install with 'pip install django-cursor-pagination' and import 'from cursor_pagination import CursorPagination'.","cause":"Incorrect import: using old import path or missing install.","error":"AttributeError: module 'cursor_pagination' has no attribute 'CursorPagination'"},{"fix":"Do not instantiate pagination manually. Use it as a class attribute in DRF view: pagination_class = MyPagination.","cause":"Calling CursorPagination directly without passing request object (DRF expects it to be instantiated by framework).","error":"TypeError: __init__() missing 1 required positional argument: 'request'"},{"fix":"Use a unique field like 'id' or a timestamp field that is unique enough. Composite ordering can help.","cause":"Ordering by a non-unique field can break pagination stability.","error":"ValueError: Cannot order by field 'name' because it is not unique and may cause duplicates. Please use a unique field for cursor pagination."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}