1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

Made QuerySet slicing return IndexError instead of DoesNotExist (and related changes).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2859 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant
2006-05-06 18:46:53 +00:00
parent 0727df90f0
commit 7a62bac56e
3 changed files with 10 additions and 7 deletions

View File

@@ -128,12 +128,12 @@ class QuerySet(object):
else:
return list(self._clone(_offset=offset, _limit=limit))[::k.step]
else:
return self._clone(_offset=k, _limit=1).get()
try:
return self._clone(_offset=k, _limit=1).get()
except self.model.DoesNotExist, e:
raise IndexError, e.args
else:
try:
return self._result_cache[k]
except IndexError:
raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name
return self._result_cache[k]
def __and__(self, other):
combined = self._combine(other)