我想創建一個模型,經理對我的購買模式: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循環?
很棒!謝謝! –