From 9a5301ccbc08d5e4f78ae6a8a39330196cdd5f66 Mon Sep 17 00:00:00 2001 From: Gary Wilson Jr Date: Sun, 27 Jul 2008 23:01:55 +0000 Subject: 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 --- docs/pagination.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docs') 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 ===================== -- cgit v1.3