Login

Tag "pagination"

Snippet List

Cachable Django Paginator

This is a modificated version of `CachedPaginator` by **daniellindsley** [https://djangosnippets.org/snippets/1173/](https://djangosnippets.org/snippets/1173/) ([web-arhive-link](https://web.archive.org/web/20150927100427/https://djangosnippets.org/snippets/1173/)). Which not only cache `result_objects`, but the `total_count` of the `queryset` too (usefull if computating the count is an expensive operation too).

  • django
  • cache
  • pagination
Read More

Dynamic Paginator Mixin

Dynamic Paginator Mixin for Django 1.8.* - 1.9.*, also work for CBV (Class Bassed View) but not for "django generic view".

  • django
  • pagination
  • paginator
Read More

Seeded Randomized Querysets w/ Pagination Mixin

Mixin to support pagination when randomizing querysets. Requirements: Postgres, Django Sessions Note: This shouldn't be used on large complex datasets. It utilizes the relatively slow method of '?' randomized sorting. Use with caution. Todo: MySQL support, Support for larger datasets

  • django
  • session
  • pagination
  • random
  • postgres
  • mixin
  • postgresql
  • cbv
  • seeded
Read More

Simple Paginate

This function wraps boilerplate code to get the current page in a view, obtaining the page number from some URL query string variable, e.g., ?page=2 The interface is inspired by the interface of Paginator. The implementation follows an example given in Django documentation.

  • pagination
  • paginator
  • paginate
Read More

deleted

nothing to see here...

  • pagination
  • paginator
  • postgresql
  • paginate
  • capped
Read More

Add querystring parameters to path (template tag)

`<h3>Page: {{ page.number }} of {{ page.paginator.num_pages }}</h3> {% if page.has_previous or page.has_next %} <div> {% if page.has_previous %} <a href="{% url_add_query page=page.previous_page_number %}">{% endif %}&laquo; Previous {% if page.has_previous %}</a>{% endif %} | {% if page.has_next %} <a href="{% url_add_query page=page.next_page_number %}">{% endif %} Next &raquo;{% if page.has_next %}</a>{% endif %} </div> {% endif %}`

  • template
  • templatetag
  • pagination
  • request
  • querystring
  • query-string
Read More

Pagination helper

You have pagination for some blog. At the bottom of the page you have space for seven page links. This module tries to always fill out those slots. It handles the corner cases for first page and last page etc. The logic for this is complex and sadly the Django pagination module does not deal with this. Also, it's a hell to implement this in Django templates. Believe me. See pydoc for detailed documentation. Running tests was done with `doctest`.

  • pagination
Read More

Digg-style pagination, and retain GET params

This snipplet is based on [Ryan Kanno's work](http://blog.localkinegrinds.com/2007/09/06/digg-style-pagination-in-django/) and [snipplet #2680](http://djangosnippets.org/snippets/2680/). The page numbers are basically composed by `pages_outside_trailing_range`, `page_range` and `pages_outside_leading_range`. The GET params in the request(except for `page` itself) are retained across different pages. This is important when you have an `order_by` param working inline.

  • pagination
Read More

Pagination Alphabetically compatible with paginator_class

This is just a modified version of a [previous snippet](http://djangosnippets.org/snippets/1364/) to make it work with unicode and with class-based ListView paginator_class To use it put this in your urls.py: `from youapp.fileyouchose import NamePaginator` `urlpatterns = patterns('',` `url(r'^example/(?P<page>[0-9]+)/$', ListView.as_view(model=myModel,template_name="mytemplate.html",paginator_class=NamePaginator,paginate_by=25), name="url_name"),` And then in your template something like this would work: {% if page_obj.has_other_pages %} <div class="row"> <div class="span12"> <div class="pagination"> <ul> {% if page_obj.has_previous %} <li><a href="{% url page page=page_obj.previous_page_number %}">Prev</a></li> {% else %} <li class="disabled"><a>Prev</a></li> {% endif %} {% for p in page_obj.paginator.pages %} <li {% if p == page_obj %}class="active"{% endif %}> <a href="{% url category_page page=p.number %}">{{ p }}</a> </li> {% endfor %} {% if page_obj.has_next %} <li><a href="{% url page page=page_obj.next_page_number %}">Next</a></li> {% else %} <li class="disabled"><a>Next</a></li> {% endif %} </ul> </div> </div> </div> {% endif %}

  • django
  • pagination
  • listview
Read More

45 snippets posted so far.