diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-07-27 23:01:55 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2008-07-27 23:01:55 +0000 |
| commit | 9a5301ccbc08d5e4f78ae6a8a39330196cdd5f66 (patch) | |
| tree | c0fc017ea0f280e82ce49a24a6eb6a5a47d8ba8c /docs | |
| parent | 6a287ed946e117d9daf757b9aff52087c93ad2ac (diff) | |
Made the Paginator class a bit more backwards compatible with the lecacy `ObjectPaginator` class by using the `ObjectPaginator`'s `_get_count` method. Instead of explicitly checking for an instance of `QuerySet`, this now allows any object with a `count()` or `__len__()` method defined to be passed to Paginator. For one, this is useful when you have custom `QuerySet`-like classes that implement a `count()` method but don't inherit from `QuerySet` explicitly.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8121 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/pagination.txt | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/pagination.txt b/docs/pagination.txt index bfdf8eea1c..28b381ac12 100644 --- a/docs/pagination.txt +++ b/docs/pagination.txt @@ -59,10 +59,12 @@ page:: ... InvalidPage -Note that you can give ``Paginator`` a list/tuple or a Django ``QuerySet``. The -only difference is in implementation; if you pass a ``QuerySet``, the -``Paginator`` will call its ``count()`` method instead of using ``len()``, -because the former is more efficient. +Note that you can give ``Paginator`` a list/tuple, a Django ``QuerySet``, or +any other object with a ``count()`` or ``__len__()`` method. When determining +the number of objects contained in the passed object, ``Paginator`` will first +try calling ``count()``, then fallback to using ``len()`` if the passed object +has no ``count()`` method. This allows objects such as Django's ``QuerySet`` to +use a more efficient ``count()`` method when available. ``Paginator`` objects ===================== |
