Задать вопрос

Тел: +7 965 3737 888

556

Просмотров

3

Ответов

Stateful paginator, digg style

This code will throw deprecation warnings in newer Django checkouts - see the http://www.djangosnippets.org/snippets/773/ for an improved version that should work with the recent trunk.

objects = MyModel.objects.all()
paginator = DiggPaginator(objects, 10, body=6, padding=2, page=7)
return render_to_response('template.html', {'paginator': paginator}

{% if paginator.has_next %}{# pagelink paginator.next #}{% endif %} {% for page in paginator.page_range %} {% if not page %} ... {% else %}{# pagelink page #} {% endif %} {% endfor %}

http://blog.elsdoerfer.name/2008/03/06/yet-another-paginator-digg-style/

Вопрос полезен? Да0/Нет0
file_2553.py(11.3Кб)
None

Ответы (3):

Ответduncanm:22.04.2008
Ответ полезен? Да0/Нет0

Sorry scratch the above it was a missing )

I have correctly implemented this but I now get Page no found at /menu/? when it was working correctly before?

Ответduncanm:22.04.2008
Ответ полезен? Да0/Нет0

I get the error: SyntaxError at /menu/ invalid syntax (views.py, line 18)

Line 18 is: class Paginator(object):

How do I fix this please?

Thanks Duncan

Ответmamat:17.03.2008
Ответ полезен? Да0/Нет0

quite nice!

i got used to using generic views so it'd be quite nice to add a 'list_detail' function... this way all that would be needed to switch over would be to change the import statement.