Login

Tag "paginator"

Snippet List

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

Ellipsis paginator decorator with first and last two items

Use this template tag to get a paginator showing the first and last two pages w/ adjacent pages using ellipsis. The `page` parameter is a page of a `Paginator` (typically the first but you can use whichever you want). In case of 50 pages, while being on the 40th, it'll give you the following iterable of `int`s (with `settings.PAGINATOR_ADJACENT_PAGES = 2`): `(1, 2,    38, 39, 40, 41, 42,    49, 50) ` You get the idea.

  • decorator
  • paginator
  • ellipsis
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

Pretty Paginator Tag

This is a modified version of the (http://djangosnippets.org/snippets/73/) paginator snippet. It works with the django paginator.

  • paginator
  • 'digg style'
Read More

Paginator for PostgreSQL

Use this paginator to make admin pages load more quickly for large tables when using PostgreSQL. It uses the reltuples statistic instead of counting the rows when there is no where clause. To use this code, add the following in your admin: `class BigTableAdmin(admin.ModelAdmin): paginator = LargeTablePaginator def get_changelist(self, request, **kwargs): return LargeTableChangeList `

  • paginator
  • postgres
  • reltuples
Read More

Simple Paginator Function

This is very simple Paginator function built over Django's Paginator. Just pass following:- 1. request object 2. object list - This is a list of object you want to paginate 3. per page - how many items you need per_page 4. paginator_range - Specify how many links you want on either side of current page link. Refer to Paginator reference [here](http://docs.djangoproject.com/en/dev/topics/pagination/)

  • paginator
  • page-range
Read More

django paginator

This a basic pagination example. It shows new 5 pnews items. We added a code to our template so we can view previous or next pages. It also show us how many pages we have.

  • django
  • paginator
Read More

yet another digg style paginator

put this code into your application's `__init__.py` it adds a mixin to the `Paginator` class that implements a digg style pagination. the mixin has just one method called `digg_page_range` that takes the current page object as the parameter. this method is an iterator which yields page numbers with `None` values representing gaps. this iterator is similar to the original paginator's method `page_range` and it can be used in your code to emit the needed markup.

  • paginator
  • digg
Read More

Digg-like pagination

My take on digg-like pagination. Save the code as 'templatetags/pagination_nav.py' in one of your apps. It relies on a 'pagination_nav.html' template. Here is a base template: {% if pages %} <div class="bottom-pagination-nav"> {% if previous_url %}<a href="{{ previous_url }}">{% else %}<span>{% endif %}&laquo; Previous{% if previous_url %}</a>{% else %}</span>{% endif %} {% for group in pages %} {% for page in group %} {% if page.current %}<span>{{ page.number }}</span>{% else %}<a href="{{ page.url }}">{{ page.number }}</a>{% endif %} {% endfor %} {% if not forloop.last %}<span>...</span>{% endif %} {% endfor %} {% if next_url %}<a href="{{ next_url }}">{% else %}<span>{% endif %}Next &raquo;{% if next_url %}</a>{% else %}</span>{% endif %} </div> {% endif %}

  • pagination
  • template-tag
  • paginator
  • digg
Read More

Paginator Tag for 1.x

This is a [Paginator Tag](http://www.djangosnippets.org/snippets/73/) for 1.x. Since the context is less overfull, the template, paginator.html, needs more logic. Put the tag in your templatetags and the template at the root of a template-directory. The tag will work out of the box in a generic view, other views must provide `is_paginated` set to True, `page_obj`, and `paginator`. You can get the `object_list` from the `page_obj`: `page_obj.object_list`. See [the pagination documentation](http://docs.djangoproject.com/en/1.0/topics/pagination/).

  • tag
  • paginator
Read More
Author: HM
  • 1
  • 4

Pagination/Filtering Alphabetically

This allows you to create an alphabetical filter for a list of objects; e.g. `Browse by title: A-G H-N O-Z`. See [this entry](http://developer.yahoo.com/ypatterns/pattern.php?pattern=alphafilterlinks) in Yahoo's design pattern library for more info. NamePaginator works like Django's Paginator. You pass in a list of objects and how many you want per letter range ("page"). Then, it will dynamically generate the "pages" so that there are approximately `per_page` objects per page. By dynamically generating the letter ranges, you avoid having too many objects in some letter ranges and too few in some. If your list is heavy on one end of the letter range, there will be more pages for that range. It splits the pages on letter boundaries, so not all the pages will have exactly `per_page` objects. However, it will decide to overflow or underflow depending on which is closer to `per_page`. **NamePaginator Arguments**: `object_list`: A list, dictionary, QuerySet, or something similar. `on`: If you specified a QuerySet, this is the field it will paginate on. In the example below, we're paginating a list of Contact objects, but the `Contact.email` string is what will be used in filtering. `per_page`: How many items you want per page. **Examples:** >>> paginator = NamePaginator(Contacts.objects.all(), \ ... on="email", per_page=10) >>> paginator.num_pages 4 >>> paginator.pages [A, B-R, S-T, U-Z] >>> paginator.count 36 >>> page = paginator.page(2) >>> page 'B-R' >>> page.start_letter 'B' >>> page.end_letter 'R' >>> page.number 2 >>> page.count 8 In your view, you have something like: contact_list = Contacts.objects.all() paginator = NamePaginator(contact_list, \ on="first_name", per_page=25) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: page = paginator.page(page) except (InvalidPage): page = paginator.page(paginator.num_pages) return render_to_response('list.html', {"page": page}) In your template, have something like: {% for object in page.object_list %} ... {% endfor %} <div class="pagination"> Browse by title: {% for p in page.paginator.pages %} {% if p == page %} <span class="selected">{{ page }}</span> {% else %} <a href="?page={{ page.number }}"> {{ page }} </a> {% endif %} {% endfor %} </div> It currently only supports paginating on alphabets (not alphanumeric) and will throw an exception if any of the strings it is paginating on are blank. You can fix either of those shortcomings pretty easily, though.

  • pagination
  • paginator
  • filtering
Read More

Example usage of SimpleCouchPaginator

Example Usage of [Very basic CouchDB Paginator](http://www.djangosnippets.org/snippets/1208/) An Example setup of CouchDB with django can be found at: [Eric Florenzanos post about django+couchdb](http://www.eflorenzano.com/blog/post/using-couchdb-django/)

  • pagination
  • paginator
  • couchdb
  • example
Read More

27 snippets posted so far.