最佳答案
我有这些模型:
def Foo(Models.model):
size = models.IntegerField()
# other fields
def is_active(self):
if check_condition:
return True
else:
return False
def Bar(Models.model):
foo = models.ForeignKey("Foo")
# other fields
现在我想查询一下那些拥有活跃 Foo 的酒吧:
Bar.objects.filter(foo.is_active())
我得到了错误,如
SyntaxError at /
('non-keyword arg after keyword arg'
我怎么才能做到呢?