【发布时间】:2010-01-13 22:57:37
【问题描述】:
我有一个名为 Product 的模型,它有一个自定义属性:
def _get_active(self):
o = get_option()
if self.date_expiration == None:
return True
if self.date_expiration <= o.working_month:
return False
return True
active = property(_get_active)
...在我的一种方法中,我有这一行:
products = g.product_set.filter(active__exact=True)
但尽管(我认为)我已经正确设置了属性,但上面的行给了我“无法将关键字 'active' 解析为字段。”我在这里错过了什么?
提前致谢。
【问题讨论】:
标签: django django-models