I've got a function built into my Django model class and I want to use that function to filter my query results.
class service:
......
def is_active(self):
if datetime.now() > self.end_time:
return False
return True
Now I want to use this function into my query filter, something like
nserv = service.objects.filter(is_active=True)
I know, for this simple 'is_active' case, I can directly make this comparision in filter query, but for more complex situations, that may not be possible. How should I make a query, based on custom functions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…