That's it! You have now paginated ``object_list`` and given users of the site
a way to navigate between the different pages--all without touching your views.
+Custom pagination templates
+---------------------------
+
+In order to override the default pagination template, declare a context variable
+named ``pagination_template`` set to the template name::
+
+ {% with 'pagination/blog/post.html' as pagination_template %}
+ {% autopaginate posts pagesize %}
+ {% paginate %}
+ {% endwith %}
+
+The default pagination template is contained in the ``pagination/default.html``
+file inside the distribution.
A Note About Uploads
--------------------
``PAGINATION_INVALID_PAGE_RAISES_404``
Determines whether an invalid page raises an ``Http404`` or just sets the
``invalid_page`` context variable. ``True`` does the former and ``False``
- does the latter.
\ No newline at end of file
+ does the latter.
+
+``DISPLAY_PAGE_LINKS``
+ If set to ``False``, links for single pages will not be displayed.
+
+``PREVIOUS_LINK_DECORATOR``
+ An HTML prefix for the previous page link; the default value is ``‹‹ ``.
+
+``NEXT_LINK_DECORATOR``
+ An HTML postfix for the next page link; the default value is `` ››``.
+
+``DISPLAY_DISABLED_PREVIOUS_LINK``
+ If set to ``False``, the previous page link will not be displayed if there's
+ no previous page.
+
+``DISPLAY_DISABLED_NEXT_LINK``
+ If set to ``False``, the next page link will not be displayed if there's no
+ next page.
--- /dev/null
+{% if is_paginated %}
+ {% load i18n %}
+ <div class="pagination">
+ {% block previouslink %}
+ {% if page_obj.has_previous %}
+ <a href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}" class="prev">{{ previous_link_decorator|safe }}{% trans "previous" %}</a>
+ {% else %}
+ {% if display_disabled_previous_link %}
+ <span class="disabled prev">{{ previous_link_decorator|safe }}{% trans "previous" %}</span>
+ {% endif %}
+ {% endif %}
+ {% endblock previouslink %}
+ {% block pagelinks %}
+ {% if display_page_links %}
+ {% for page in pages %}
+ {% if page %}
+ {% ifequal page page_obj.number %}
+ <span class="current page">{{ page }}</span>
+ {% else %}
+ <a href="?page={{ page }}{{ getvars }}{{ hashtag }}" class="page">{{ page }}</a>
+ {% endifequal %}
+ {% else %}
+ ...
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+ {% endblock pagelinks %}
+ {% block nextlink %}
+ {% if page_obj.has_next %}
+ <a href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}" class="next">{% trans "next" %}{{ next_link_decorator|safe }}</a>
+ {% else %}
+ {% if display_disabled_next_link %}
+ <span class="disabled next">{% trans "next" %}{{ next_link_decorator|safe }}</span>
+ {% endif %}
+ {% endif %}
+ {% endblock nextlink %}
+ </div>
+{% endif %}
\ No newline at end of file
-{% if is_paginated %}
-{% load i18n %}
-<div class="pagination">
- {% if page_obj.has_previous %}
- <a href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}" class="prev">{{ previous_link_decorator }}{% trans "previous" %}</a>
- {% else %}
- {% if display_disabled_previous_link %}
- <span class="disabled prev">{{ previous_link_decorator }}{% trans "previous" %}</span>
- {% endif %}
- {% endif %}
- {% if display_page_links %}
- {% for page in pages %}
- {% if page %}
- {% ifequal page page_obj.number %}
- <span class="current page">{{ page }}</span>
- {% else %}
- <a href="?page={{ page }}{{ getvars }}{{ hashtag }}" class="page">{{ page }}</a>
- {% endifequal %}
- {% else %}
- ...
- {% endif %}
- {% endfor %}
- {% endif %}
- {% if page_obj.has_next %}
- <a href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}" class="next">{% trans "next" %}{{ next_link_decorator }}</a>
- {% else %}
- {% if display_disabled_next_link %}
- <span class="disabled next">{% trans "next" %}{{ next_link_decorator }}</span>
- {% endif %}
- {% endif %}
-</div>
-{% endif %}
\ No newline at end of file
+{% include pagination_template %}
A dictionary of all of the **GET** parameters in the current request.
This is useful to maintain certain types of state, even when requesting
a different page.
- """
+
+ ``pagination_template``
+ A custom template to include in place of the default ``pagination.html``
+ contents.
+
+ """
try:
paginator = context['paginator']
page_obj = context['page_obj']
page_range = paginator.page_range
+ pagination_template = context.get('pagination_template', 'pagination/default.html')
# Calculate the record range in the current page for display.
records = {'first': 1 + (page_obj.number - 1) * paginator.per_page}
records['last'] = records['first'] + paginator.per_page - 1
'display_disabled_next_link': DISPLAY_DISABLED_NEXT_LINK,
'previous_link_decorator': PREVIOUS_LINK_DECORATOR,
'next_link_decorator': NEXT_LINK_DECORATOR,
+ 'pagination_template': pagination_template,
}
if 'request' in context:
getvars = context['request'].GET.copy()