diff --git a/django/db/models/query.py b/django/db/models/query.py index 12b2ff9d318..e01905551e2 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -109,6 +109,8 @@ class QuerySet(object): def __getitem__(self, k): "Retrieve an item or slice from the set of results." + if not isinstance(k, (slice, int)): + raise TypeError 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."