0
class Quarter(models.Model):
...
class House(models.Model):
quarter = models.ForeignKey(Quarter, related_name='houses')
class FloorRange(models.Model):
house = models.ForeignKey(House, related_name='floor_ranges')
is_commercial = models.BooleanField(default=False)
幫我找得到Quarter
對象,其中houses
有一個或多個floor_ranges
與is_commercial=True
Django的查詢集與過濾相關對象
謝謝你,我想在一行的更好:House.objects.filter(季=季度,floor_ranges__is_commercial = FALSE).distinct() – 2014-10-15 16:55:39
當然,我把它分解成多行,使之更容易說明。 – Alasdair 2014-10-15 16:56:37