Django: A Result Specific Numeration for Pagination.

Posted by TheLizardKing on Stack Overflow See other posts from Stack Overflow or by TheLizardKing
Published on 2010-04-04T03:57:51Z Indexed on 2010/04/04 4:03 UTC
Read the original article Hit count: 466

Filed under:
|
|

Simply put I want what http://www.reddit.com/ and http://news.ycombinator.com/ have to the left of every link. A numerated link starting with 1 and continuing to the next page by means of pagination.

I really enjoy using generic views and their built-in pagination for Django and it seems to allow me access to these values if I was on page 3 with 2 items per page.

{'MEDIA_URL': ''}
{'LANGUAGES': '<<languages>>',
 'LANGUAGE_BIDI': False,
 'LANGUAGE_CODE': 'en-us'}
{'debug': True, 'sql_queries': '<<sql_queries>>'}
{'messages': [],
 'perms': <django.core.context_processors.PermWrapper object at 0xadedeec>,
 'user': <User: thelizardking>}
{'first_on_page': 5,
 'has_next': True,
 'has_previous': True,
 'hits': 7,
 'is_paginated': True,
 'last_on_page': 6,
 'links_list': [<Link: Funky Town>, <Link: Apple Jax>],
 'next': 4,
 'page': 3,
 'page_obj': <Page 3 of 4>,
 'page_range': [1, 2, 3, 4],
 'pages': 4,
 'paginator': <django.core.paginator.Paginator object at 0xadf914c>,
 'previous': 2,
 'results_per_page': 2}

I know there is an add filter for templates but that's as close as I think I can get and that really doesn't do what I want. Am I going to have to use a custom template filter here or is there something I am not seeing?

© Stack Overflow or respective owner

Related posts about django

Related posts about pagination