Changeset 7819
- Timestamp:
- 07/01/08 23:31:28 (3 months ago)
- Files:
-
- django/trunk/django/core/paginator.py (modified) (1 diff)
- django/trunk/tests/modeltests/pagination/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/paginator.py
r7353 r7819 174 174 try: 175 175 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). 177 180 self._count = len(self.object_list) 178 181 return self._count django/trunk/tests/modeltests/pagination/models.py
r7308 r7819 201 201 [1] 202 202 203 # ObjectPaginator can be passed lists too. 204 >>> paginator = ObjectPaginator([1, 2, 3], 5) 205 >>> paginator.hits 206 3 207 >>> paginator.pages 208 1 209 >>> paginator.page_range 210 [1] 211 212 213 # ObjectPaginator can be passed other objects with a count() method. 214 >>> class Container: 215 ... def __len__(self): 216 ... return 42 217 >>> paginator = ObjectPaginator(Container(), 10) 218 >>> paginator.hits 219 42 220 >>> paginator.pages 221 5 222 >>> paginator.page_range 223 [1, 2, 3, 4, 5] 224 225 203 226 ################## 204 227 # Orphan support #
