mirror of
https://github.com/django/django.git
synced 2025-10-29 08:36:09 +00:00
Improved error message when index in __getitem__() is invalid.
This commit is contained in:
committed by
Mariusz Felisiak
parent
8323691de0
commit
d89053585e
@@ -283,7 +283,10 @@ class QuerySet:
|
||||
def __getitem__(self, k):
|
||||
"""Retrieve an item or slice from the set of results."""
|
||||
if not isinstance(k, (int, slice)):
|
||||
raise TypeError
|
||||
raise TypeError(
|
||||
'QuerySet indices must be integers or slices, not %s.'
|
||||
% type(k).__name__
|
||||
)
|
||||
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))), \
|
||||
|
||||
Reference in New Issue
Block a user