我在模型中有以下功能:
@property
def exclusive_price(self):
if(self.discount_price > 0):
return self.list_price - self.discount_price
else:
return self.list_price
我尝试在模板中调用它,但没有输出任何内容。我该怎么办?
{{obj.exlusive_price}}
答案 0 :(得分:15)
它无效,因为您调用的是exlusive_price而不是exclusive_price。 c缺失了。
答案 1 :(得分:1)
假设这不是剪切和粘贴错误,您的方法称为exclusive_price
,但是您在没有exlusive_price
的情况下调用c
。