1
0
mirror of https://github.com/django/django.git synced 2025-04-19 23:04:36 +00:00

magic-removal: fixed bug with indexing in QuerySet.__getitem__

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2201 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant 2006-01-31 02:22:54 +00:00
parent e51fcf8ec3
commit 758f1366c2

View File

@ -98,7 +98,11 @@ class QuerySet(object):
# both be None at this point.
if self._result_cache is None:
if isinstance(k, slice):
return list(self._clone(_offset=k.start, _limit=k.stop))[::k.step]
if k.stop is not None and k.start is not None:
limit = k.stop - k.start
else:
limit = k.stop
return list(self._clone(_offset=k.start, _limit=limit))[::k.step]
else:
return self._clone(_offset=k, _limit=1).get()
else: