1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Improved error message when index in __getitem__() is invalid.

This commit is contained in:
Jon Dufresne
2019-07-19 13:55:32 -07:00
committed by Mariusz Felisiak
parent 8323691de0
commit d89053585e
6 changed files with 28 additions and 4 deletions

View File

@@ -63,7 +63,10 @@ class BoundField:
# Prevent unnecessary reevaluation when accessing BoundField's attrs
# from templates.
if not isinstance(idx, (int, slice)):
raise TypeError
raise TypeError(
'BoundField indices must be integers or slices, not %s.'
% type(idx).__name__
)
return self.subwidgets[idx]
@property