Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pennersr/django-pagemore
KISS approach to a "Load more" style AJAX paginator
https://github.com/pennersr/django-pagemore
Last synced: 3 months ago
JSON representation
KISS approach to a "Load more" style AJAX paginator
- Host: GitHub
- URL: https://github.com/pennersr/django-pagemore
- Owner: pennersr
- License: bsd-3-clause
- Archived: true
- Created: 2012-11-09T09:33:59.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-03-13T17:48:36.000Z (over 7 years ago)
- Last Synced: 2024-06-25T11:44:41.348Z (5 months ago)
- Language: Python
- Size: 17.6 KB
- Stars: 54
- Watchers: 10
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
===============
django-pagemore
===============KISS approach to a "Load more" style AJAX paginator
Requirements
============- Django 1.3+
- jQueryFeatures
========- Non-intrusive: your Django view is completely unaware of dynamic
load-more stuff going on.
- There is literally no code (no Python, no Javascript) required to
get a fully AJAX style "load more" going.
- KISSQuickstart
==========- Write your view as usual, handing over an (unpaginated) list of
items to a template.
- Render the list of items in your template as follows::{% load pagemore %}
{% more_paginator items per_page=10 ordered_by="-created_at" as paginator %}
{% for item in paginator.objects %}
{% if forloop.first %}
{% endif %}
{{item}}
{% if forloop.last %}
{% if paginator.has_more %}
More items...
{% endif %}
{% endif %}
{% endfor %}
$(function() { $(".pagemore-paginator").pagemore(); });
- That's all!
Pagination Strategies
=====================When a user is paginating through a list of items, while at the same
time new items are being inserted, offset based slicing would result
in duplicate items being shown. A way to circumvent this is to make
sure that the items are properly ordered and to filter on items after
a certain point. Both strategies are supported.Paginate by Slicing
-------------------Usage::
{% more_paginator ... strategy="slice" ... %}
Characteristics:
- Supports both querysets and lists
- Does not order the objects unless explicitly told to (`ordered_by`).
Paginate by Filtering
---------------------Usage::
{% more_paginator ... strategy="filter" ... %}
Characteristics:
- Only supports querysets
- Enforces an ordering of the objects passed (default on `id`, overridable
by `ordered_by`).