我有这两个模型:
class InspectionPoint(models.Model):
...
review_check = models.BooleanField(default = 0)
flight = models.ForeignKey(
Flight,
related_name='inspection_points',
on_delete=models.CASCADE,
null=True, blank=True
)
...
class ImageSnapshot(models.Model):
...
inspection = models.ForeignKey(
InspectionPoint,
on_delete=models.CASCADE,
related_name = 'snapshots'
)
flight = models.ForeignKey(
Flight,
related_name='snapshots',
on_delete=models.CASCADE,
null=True, blank=True
)
...
我已经有快照查询集:snapshots = ImageSnapshots.objects.filter(flight=flight)
但是这给了我所有的快照。
我想过滤的快照只有(review_check = True)
任何想法?
试试这个:
ImageSnapshot.objects.filter(flight=flight, inspection__review_check=True)