mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
Made negative indexing on QuerySet instances raise an assertion error (previously
it just returned incorrect results). git-svn-id: http://code.djangoproject.com/svn/django/trunk@2992 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -95,6 +95,9 @@ class QuerySet(object):
|
||||
|
||||
def __getitem__(self, k):
|
||||
"Retrieve an item or slice from the set of results."
|
||||
assert (not isinstance(k, slice) and (k >= 0)) \
|
||||
or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0)), \
|
||||
"Negative indexing is not supported."
|
||||
if self._result_cache is None:
|
||||
if isinstance(k, slice):
|
||||
# Offset:
|
||||
|
||||
Reference in New Issue
Block a user