mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
Fixed #16383 -- Raised the AttributeError raised in property of an object when used in a template.
Thanks maraujop for the report and Hiroki and Tim Graham for review.
This commit is contained in:
committed by
Tim Graham
parent
9d9f0acd7e
commit
0dd05c9e66
@@ -773,7 +773,10 @@ class Variable(object):
|
||||
if isinstance(current, BaseContext) and getattr(type(current), bit):
|
||||
raise AttributeError
|
||||
current = getattr(current, bit)
|
||||
except (TypeError, AttributeError):
|
||||
except (TypeError, AttributeError) as e:
|
||||
# Reraise an AttributeError raised by a @property
|
||||
if isinstance(e, AttributeError) and not isinstance(current, BaseContext) and bit in dir(current):
|
||||
raise
|
||||
try: # list-index lookup
|
||||
current = current[int(bit)]
|
||||
except (IndexError, # list index out of range
|
||||
|
||||
Reference in New Issue
Block a user