{ "info": { "author": "Ilya Semenov", "author_email": "ilya@semenov.co", "bugtrack_url": null, "classifiers": [], "description": "django-sequential-pagination\n============================\n\nPaginate ordered Django querysets sequentially with \"Next\" button. Fully compatible with `django-el-pagination`_ (but doesn't depend on it).\n\nThe pagination is performed by object ID (or any other set of fields that give strict linear order) rather than by page number. Instead of ``?page=2``, ``?page=3``, etc., it produces links like ``?from=11``, ``?from=21`` and so on. This gives the following benefits:\n\n* The pagination works extremely fast even on huge data sets. For example, on Postgres \"normal\" pagination may take seconds (or even minutes) on queries like ``?page=1000000``.\n\n* It prevents duplicates on next page when new data is injected at top and shifts page boundaries (this is especially important for AJAX pagination).\n\nThe drawback is that there is no navigation to arbitrary page number and no reverse navigation, it's always only the link to \"Next page\" (or nothing at the last page).\n\n.. _django-el-pagination: https://github.com/shtalinberg/django-el-pagination\n\n\nInstallation\n============\n\n::\n\n pip install django-sequential-pagination\n\n\nUsage\n=====\n\nAdd ``django_sequential_pagination`` to ``INSTALLED_APPS``:\n\n.. code:: python\n\n\t# settings.py\n\n\tINSTALLED_APPS = [\n\t\t...\n\t\t'django_sequential_pagination',\n\t]\n\n\nPass an *ordered* queryset to the template:\n\n.. code:: python\n\n\t# views.py\n\t\n\tdef recent_posts(request):\n\t\treturn render(request, \"blog/posts.html\", {\n\t\t\t'posts': Post.objects.all().order_by('-time', '-id'),\n\t\t})\n\n\nMake sure that the ordering always has a tie breaker as the last key, otherwise you may get duplicates on page boundaries.\n\nNow, paginate objects in the template:\n\n.. code:: django\n\n\t{% load pagination %}\n\n\t{% paginate posts per_page=10 as page %}\n\n\t{% for post in page.objects %}\n\t\t