From 758f1366c2765c303444c0fb56cd62858ddb9483 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Tue, 31 Jan 2006 02:22:54 +0000 Subject: [PATCH] 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 --- django/db/models/query.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django/db/models/query.py b/django/db/models/query.py index 18493dac34..d95422aa10 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -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: