mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Improved error message when index in __getitem__() is invalid.
This commit is contained in:
committed by
Mariusz Felisiak
parent
8323691de0
commit
d89053585e
@@ -151,7 +151,10 @@ class Page(collections.abc.Sequence):
|
||||
|
||||
def __getitem__(self, index):
|
||||
if not isinstance(index, (int, slice)):
|
||||
raise TypeError
|
||||
raise TypeError(
|
||||
'Page indices must be integers or slices, not %s.'
|
||||
% type(index).__name__
|
||||
)
|
||||
# The object_list is converted to a list so that if it was a QuerySet
|
||||
# it won't be a database hit per __getitem__.
|
||||
if not isinstance(self.object_list, list):
|
||||
|
||||
Reference in New Issue
Block a user