mirror of
https://github.com/django/django.git
synced 2025-10-25 14:46:09 +00:00
Made legacy ObjectPaginator truly backwards-compatible by catching both AttributeError and TypeError in _get_count as it did before
[7306]. Tests included. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7819 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -173,7 +173,10 @@ class ObjectPaginator(Paginator):
|
||||
if self._count is None:
|
||||
try:
|
||||
self._count = self.object_list.count()
|
||||
except TypeError:
|
||||
except (AttributeError, TypeError):
|
||||
# AttributeError if object_list has no count() method.
|
||||
# TypeError if object_list.count() requires arguments
|
||||
# (i.e. is of type list).
|
||||
self._count = len(self.object_list)
|
||||
return self._count
|
||||
count = property(_get_count)
|
||||
|
||||
Reference in New Issue
Block a user