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.