我想创建一个模型,经理对我的购买模式:Django的查询集 - 在相关对象的布尔值筛选对象
class Purchase(models.Model)
number = models.IntegerField
class InventoryLog(models.Model)
purchase = models.ForeignKey(Purchase)
sold_out = models.BooleanField(default=false)
我想我的模型管理器返回任何Purchase
对象不相关到InventoryLog
对象与值True
有没有办法处理这与查询集,Q对象或F对象,或者我需要诉诸for循环?
很棒!谢谢! –