{"id":19372079,"url":"https://github.com/fengsp/pypages","last_synced_at":"2025-04-23T16:31:49.474Z","repository":{"id":16761306,"uuid":"19519164","full_name":"fengsp/pypages","owner":"fengsp","description":"Simple Python Pagination","archived":false,"fork":false,"pushed_at":"2014-06-25T04:44:17.000Z","size":216,"stargazers_count":9,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T17:22:24.744Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fengsp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","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":"2014-05-07T02:58:36.000Z","updated_at":"2024-01-04T15:56:44.000Z","dependencies_parsed_at":"2022-08-25T11:00:45.646Z","dependency_job_id":null,"html_url":"https://github.com/fengsp/pypages","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fpypages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fpypages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fpypages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fpypages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fengsp","download_url":"https://codeload.github.com/fengsp/pypages/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249817532,"owners_count":21329411,"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-11-10T08:21:30.964Z","updated_at":"2025-04-23T16:31:49.188Z","avatar_url":"https://github.com/fengsp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"##PyPages: Easier Pagination\n\n\u003cbr\u003e\n**Do pagination in python like a charm.**\n\n##install\n\n    pip install PyPages\n\n##usage\n\n```python\nfrom pypages import Paginator\n\n# Inside view func\ndef view():\n    # get current page\n    page = 3\n    # retrieve the objects of the certain page\n    # you should handle your data pagination yourself(database query or other ways)\n    # make sure use the same per_page value and pass in the right objects total number\n    objects = range(10)\n    p = Paginator(100, per_page=10, current=page, range_num=5)\n    # you can attach your objects to the paginator\n    p.objects = objects\n    return render_all(p=p)\n    \ndef render_all(p):\n    print \"Your objects:\"\n    for o in p.objects:\n        print o\n    print \"Your pages:\"\n    print \"\u003cul\u003e\"\n    print \"\u003cli\u003e\u003ca href='1'\u003efirst\u003c/a\u003e\u003c/li\u003e\"\n    for page in p.pages:\n        if page == p.current:\n            print \"\u003cli\u003e%s\u003c/li\u003e\" % page\n        else:\n            print \"\u003cli\u003e\u003ca href='%s'\u003e%s\u003c/a\u003e\u003c/li\u003e\" % (page, page)\n    print \"\u003cli\u003e\u003ca href='%s'\u003elast\u003c/a\u003e\u003c/li\u003e\" % p.page_num\n    print \"\u003c/ul\u003e\"\n\ndef render(p):\n    print \"Your objects:\"\n    for o in p.objects:\n        print o\n    print \"Your pages:\"\n    print \"\u003cul\u003e\"\n    if p.has_previous:\n        print \"\u003cli\u003e\u003ca href='%s'\u003eprevious\u003c/a\u003e\u003c/li\u003e\" % p.previous\n    print \"\u003cli\u003e%s/%s\u003c/li\u003e\" % (p.current, p.page_num)\n    if p.next: # pythonic, of course you can check p.has_next too\n        print \"\u003cli\u003e\u003ca href='%s'\u003enext\u003c/a\u003e\u003c/li\u003e\" % p.next\n    print \"\u003c/ul\u003e\"\n```\n\n##api\n\n*class* pypages.**Paginator**(*object_num, per_page=10, current=1, start=None, range_num=10*)  \n***Parameters:***  \n\n* **object_num** – the total number of items\n* **per_page** – the maximum number of items to include on a page, default 10\n* **current** – the current page number, default 1\n* **start** – the start index for your page range, default to be current page minus half of the page range length\n* **range_num** – the maximum page range length, default 10\n\n    NOTICE: **page range** is the pages that will be displayed, like you have one page \"5, 6, 7, 8, 9, 10\", then your page range ``start`` is 5 and ``range_num`` is 6.\n\n***Attributes:*** \n\n* **object_num** - the total number of items\n* **per_page** – the maximum number of items to include on a page\n* **current** – the current page number\n* **start** – the start index for your page range\n* **range_num** – the maximum page range length\n* **end** - the end index for your page range\n* **page_num** - the total number of pages\n* **pages** - the page range, a list like `[4, 5, 6, 7, 8]`\n* **has_previous** - bool value to indicate whether current page have previous page\n* **has_next** - bool value to indicate whether current page have next page\n* **previous** - the previous page number, if do not exist, will be `None`\n* **next** - the next page number, if do not exist, will be `None`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengsp%2Fpypages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffengsp%2Fpypages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengsp%2Fpypages/lists"}