Django

Code

Show
Ignore:
Timestamp:
07/01/08 23:31:28 (5 months ago)
Author:
gwilson
Message:

Made legacy ObjectPaginator truly backwards-compatible by catching both AttributeError and TypeError in _get_count as it did before
[7306]. Tests included.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/paginator.py

    r7353 r7819  
    174174            try: 
    175175                self._count = self.object_list.count() 
    176             except TypeError: 
     176            except (AttributeError, TypeError): 
     177                # AttributeError if object_list has no count() method. 
     178                # TypeError if object_list.count() requires arguments 
     179                # (i.e. is of type list). 
    177180                self._count = len(self.object_list) 
    178181        return self._count