{"id":16603307,"url":"https://github.com/dbrgn/django-simplepaginator","last_synced_at":"2025-09-28T17:31:04.564Z","repository":{"id":57467532,"uuid":"2199531","full_name":"dbrgn/django-simplepaginator","owner":"dbrgn","description":"A simple wrapper around the Django paginator.","archived":false,"fork":false,"pushed_at":"2014-01-31T14:32:53.000Z","size":241,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-12T10:42:13.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbrgn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-12T22:32:00.000Z","updated_at":"2024-01-17T18:14:51.000Z","dependencies_parsed_at":"2022-09-19T08:51:11.868Z","dependency_job_id":null,"html_url":"https://github.com/dbrgn/django-simplepaginator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbrgn%2Fdjango-simplepaginator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbrgn%2Fdjango-simplepaginator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbrgn%2Fdjango-simplepaginator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbrgn%2Fdjango-simplepaginator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbrgn","download_url":"https://codeload.github.com/dbrgn/django-simplepaginator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234452073,"owners_count":18834740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T00:49:14.470Z","updated_at":"2025-09-28T17:31:04.124Z","avatar_url":"https://github.com/dbrgn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-simplepaginator\n======================\n\n[![Build Status](https://travis-ci.org/dbrgn/django-simplepaginator.png)]\n(https://travis-ci.org/dbrgn/django-simplepaginator)\n[![Build Status](https://pypip.in/d/django-simplepaginator/badge.png)]\n(https://pypi.python.org/pypi/simple_paginator)\n\ndjango-simplepaginator is a small wrapper around the standard Django paginator. The goal of\ndjango-simplepaginator is _not_ to replace the Django paginator with yet another kind of pagination\ninterface. It just simplifies the creation of a pagination and provides templates for column\ntitles and page navigation. It supports sorting and orphans.\n\nInstallation\n------------\n\nCopy the simple_paginator folder to your project or install it into your pythonpath:\n\n    # python setup.py install\n\nIf you use pip, you can also install it directly using the -e parameter:\n\n    # pip install -e git://github.com/dbrgn/django-simplepaginator.git#egg=simple_paginator\n\nThen add simple_paginator to your `INSTALLED_APPS` setting.\n\nUsage\n-----\n\nThe SimplePaginator object accepts the following keyword arguments:\n\n* `request` -- The request object\n* `prefix` -- The prefix for the controls' css-class and for the GET parameters\n* `data` -- Elements to paginate\n* `columns` -- A tuple of tuples containing column name and key (default None)\n* `per_page` -- How many elements to display per page (default 20)\n* `orphans` -- Whether to move orphans to the previous page (default 1)\n\nIn the view, use the `paginate()`-shortcutfunction to return pagination items. Remember that each\npagination on a page must have a distinct prefix.\n\nColumns can be marked as non-sortable by setting the sort key to `None`.\n\n### Example:\n\n```python\nfrom django.shortcuts import render_to_response\nimport simple_paginator\n\ntry:\n    objects = models.Example.objects.filter(id__lte=100)\nexcept ObjectDoesNotExist:\n    objects = None\n\nprefix = 'itemlist'\ncolumns = (\n    ('Column1', 'modelfield1'),\n    ('Column2', 'modelfield2'),\n    ('Column3', None),\n)\nitems, order, baseurl = simple_paginator.paginate(request, prefix, functions, columns)\n\ncontext = {\n    'items': items,\n    'prefix': prefix,\n    'columns': columns,\n    'order': order,\n    'baseurl': baseurl\n}\nreturn render_to_response('template.html', context)\n```\n\nAnd in the template:\n\n```html\n\u003ch1\u003ePagination demo\u003c/h1\u003e\n\u003cp\u003eThis pagination shows all Example objects with an id \u003c= 100.\u003c/p\u003e\n\n\u003cdiv class=\"simple_paginator\"\u003e\n    \u003ctable\u003e\n        {% include 'simple_paginator/paginator_header.html' %}\n            {% for item in items.object_list %}\n                \u003ctr class=\"{% cycle 'odd' 'even' %}\"\u003e\n                    \u003ctd\u003e{{ item.modelfield1 }}\u003c/td\u003e\n                    \u003ctd\u003e{{ item.modelfield2 }}\u003c/td\u003e\n                    \u003ctd\u003e{{ item.modelfield3 }}\u003c/td\u003e\n                \u003c/tr\u003e\n            {% endfor %}\n    \u003c/table\u003e\n\n    {% include 'simple_paginator/paginator_control.html' %}\n\u003c/div\u003e\n```\n\nIf the column/sorting feature is not used, some parts can be omitted:\n\n```html\n\u003ch1\u003ePagination demo\u003c/h1\u003e\n\u003cp\u003eThis pagination lists some items.\u003c/p\u003e\n\n\u003cdiv class=\"simple_paginator\"\u003e\n    {% for item in items.object_list %}\n        \u003cdiv class=\"item\"\u003e{{ item }}\u003c/div\u003e\n    {% endfor %}\n\n    {% include 'simple_paginator/paginator_control.html' %}\n\u003c/div\u003e\n```\n\nCustomization\n-------------\n\nYou can customize the paginator header and control templates by copying them to your project\nfolder and editing them, or by adding completely new templates. They should be put in a\ndirectory called \"simple_paginator\" inside your template folder.\n\nPlease keep in mind that most of the control logic is done inside those templates, so be careful\nchanging them.\n\nChangelog\n---------\n\nv0.3.1 (2014-01-31)\n\n- [add] Added possibility to sort by model methods (#2)\n\nv0.3.0 (2013-08-21)\n\n- [bug] Removed `\u003cdiv\u003e` from `paginator_header.html` template (#1)\n\nv0.2.2 (2011-09-07)\n\n- [add] Feature to mark columns as non-sortable\n\nv0.2.1 (2011-08-30)\n\n- [bug] Fixed compatibility with Python 2.5\n\nv0.2 (2011-08-26)\n\n- [add] Published django-simplepaginator on Github\n- [bug] Fixed critical bugs in view and templates\n- [bug] Fixed problems with setup.py\n\nLicense\n-------\n\nCopyright 2011-2013 Danilo Bargen (http://dbrgn.ch/)\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU\nLesser General Public License as published by the Free Software Foundation, either version 3 of the\nLicense, or any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\neven the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser\nGeneral Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along with this program.\nIf not, see http://www.gnu.org/licenses/lgpl.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbrgn%2Fdjango-simplepaginator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbrgn%2Fdjango-simplepaginator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbrgn%2Fdjango-simplepaginator/lists"}