Changelog

Version 1.0

Feature: Python 3 support.

Django Endless Pagination Angular supports both Python 2 and Python 3. Dropped support for Python 2.5. See Getting started for the new list of requirements.


Feature: the JavaScript refactoring.

This version replace Jquery by Angular.Js a re-designed Ajax support for pagination. It was removed file static/endless_pagination/js/endless-pagination.js and replaced for static/endless_pagination/js/module.endless.js.

Usage:

{% block js %}
    {{ block.super }}
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
    <script src="{{ STATIC_URL }}endless_pagination/js/module.endless.js"></script>
{% endblock %}

The last line in the block above enables Ajax requests to retrieve new pages for each pagination in the page. That’s basically the same as the old approach of loading the file endless_pagination.js. The new approach, however, is more increases the flexibility thank you to Angular.js.

This application not is compatibility with older version of django-endless-pagination.

Please refer to the JavaScript reference for a detailed overview of the new features and for instructions on how to migrate from the old JavaScript files to the new one.


Feature: the page_templates decorator also accepts a sequence of (template, key) pairs, functioning as a dict mapping templates and keys (still present), e.g.:

from endless_pagination.decorators import page_templates

@page_templates((
    ('myapp/entries_page.html', None),
    ('myapp/other_entries_page.html', 'other_entries_page'),
))
def entry_index():
    ...

This also supports serving different paginated objects with the same template.


Feature: ability to provide nested context variables in the paginate and lazy_paginate template tags, e.g.:

{% paginate entries.all as myentries %}

The code above is basically equivalent to:

{% with entries.all as myentries %}
    {% paginate myentries %}
{% endwith %}

In this case, and only in this case, the as argument is mandatory, and a TemplateSyntaxError will be raised if the variable name is missing.


Feature: the page list object returned by the get_pages template tag has been improved adding the following new methods:

{# whether the page list contains more than one page #}
{{ pages.paginated }}

{# the 1-based index of the first item on the current page #}
{{ pages.current_start_index }}

{# the 1-based index of the last item on the current page #}
{{ pages.current_end_index }}

{# the total number of objects, across all pages #}
{{ pages.total_count }}

{# the first page represented as an arrow #}
{{ pages.first_as_arrow }}

{# the last page represented as an arrow #}
{{ pages.last_as_arrow }}

In the arrow representation, the page label defaults to << for the first page and to >> for the last one. As a consequence, the labels of the previous and next pages are now single brackets, respectively < and >. First and last pages’ labels can be customized using settings.ENDLESS_PAGINATION_FIRST_LABEL and settings.ENDLESS_PAGINATION_LAST_LABEL: see Customization.


Feature: The sequence returned by the callable settings.ENDLESS_PAGINATION_PAGE_LIST_CALLABLE can now contain two new values:

  • ‘first’: will display the first page as an arrow;
  • ‘last’: will display the last page as an arrow.

The show_pages template tag documentation describes how to customize Digg-style pagination defining your own page list callable.

When using the default Digg-style pagination (i.e. when settings.ENDLESS_PAGINATION_PAGE_LIST_CALLABLE is set to None), it is possible to enable first / last page arrows by setting the new flag settings.ENDLESS_PAGINATION_DEFAULT_CALLABLE_ARROWS to True.


Feature: settings.ENDLESS_PAGINATION_PAGE_LIST_CALLABLE can now be either a callable or a dotted path to a callable, e.g.:

ENDLESS_PAGINATION_PAGE_LIST_CALLABLE = 'path.to.callable'

In addition to the default, endless_pagination.utils.get_page_numbers, an alternative implementation is now available: endless_pagination.utils.get_elastic_page_numbers. It adapts its output to the number of pages, making it arguably more usable when there are many of them. To enable it, add the following line to your settings.py:

ENDLESS_PAGINATION_PAGE_LIST_CALLABLE = (
    'endless_pagination.utils.get_elastic_page_numbers')

Feature: ability to create a development and testing environment (see Contributing).


Feature: in addition to the ability to provide a customized pagination URL as a context variable, the paginate and lazy_paginate tags now support hardcoded pagination URL endpoints, e.g.:

{% paginate 20 entries with "/mypage/" %}

Feature: ability to specify negative indexes as values for the starting from page argument of the paginate template tag.

When changing the default page, it is now possible to reference the last page (or the second last page, and so on) by using negative indexes, e.g:

{% paginate entries starting from page -1 %}

See Templatetags reference.


Documentation: general clean up.


Documentation: added a Contributing page. Have a look!


Documentation: included a comprehensive JavaScript reference.


Fix: endless_pagination.views.AjaxListView no longer subclasses django.views.generic.list.ListView. Instead, the base objects and mixins composing the final view are now defined by this app.

This change eliminates the ambiguity of having two separate pagination machineries in place: the Django Endless Pagination Angular one and the built-in Django ListView one.


Fix: the using argument of paginate and lazy_paginate template tags now correctly handles querystring keys containing dashes, e.g.:

{% lazy_paginate entries using "entries-page" %}

Fix: replaced namespace endless_pagination.paginator with endless_pagination.paginators: the module contains more than one paginator classes.


Fix: in some corner cases, loading endless_pagination.models raised an ImproperlyConfigured error while trying to pre-load the templates.


Fix: replaced doctests with proper unittests. Improved the code coverage as a consequence. Also introduced integration tests exercising JavaScript, based on Selenium.


Fix: overall code lint and clean up.

Feature: added ability to avoid Http requests when multiple pagination is used.

A template for multiple pagination with Http support may look like this (see Multiple paginations in the same page):

<body ng-app="EndlessPagination">
    <h2>Entries:</h2>
    <div class="endless_page_template" endless-pagination>
        {% include "myapp/entries_page.html" %}
    </div>

    <h2>Other entries:</h2>
    <div class="endless_page_template" endless-pagination>
        {% include "myapp/other_entries_page.html" %}
    </div>

    {% block js %}
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
        <script src="{{ STATIC_URL }}endless_pagination/js/module.endless.js"></script>
    {% endblock %}
</div>

But what if you need Ajax pagination for entries but not for other entries? You will only have to add a class named endless_page_skip to the page container element, e.g.:

<h2>Other entries:</h2>
<div class="endless_page_template endless_page_skip" endless-pagination>
    {% include "myapp/other_entries_page.html" %}
</div>

Feature: implemented a class-based generic view allowing Ajax pagination of a list of objects (usually a queryset).

Intended as a substitution of django.views.generic.ListView, it recreates the behaviour of the page_template decorator.

For a complete explanation, see Generic views.


Fix: tests are now compatible with Django 1.3.