Changeset 2992
- Timestamp:
- 05/26/06 13:41:03 (2 years ago)
- Files:
-
- django/trunk/django/db/models/query.py (modified) (1 diff)
- django/trunk/tests/modeltests/basic/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/query.py
r2970 r2992 96 96 def __getitem__(self, k): 97 97 "Retrieve an item or slice from the set of results." 98 assert (not isinstance(k, slice) and (k >= 0)) \ 99 or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0)), \ 100 "Negative indexing is not supported." 98 101 if self._result_cache is None: 99 102 if isinstance(k, slice): django/trunk/tests/modeltests/basic/models.py
r2898 r2992 284 284 AssertionError: Cannot combine queries once a slice has been taken. 285 285 286 # Negative slices are not supported, due to database constraints. 287 # (hint: inverting your ordering might do what you need). 288 >>> Article.objects.all()[-1] 289 Traceback (most recent call last): 290 ... 291 AssertionError: Negative indexing is not supported. 292 >>> Article.objects.all()[0:-5] 293 Traceback (most recent call last): 294 ... 295 AssertionError: Negative indexing is not supported. 286 296 287 297 # An Article instance doesn't have access to the "objects" attribute.
