I have these two models:
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
)
...
I already have snapshots queryset with:
snapshots = ImageSnapshots.objects.filter(flight=flight)
but that gives me all snapshots.
I want to filter snapshots that have only (review_check = True)
Any idea?
CodePudding user response:
Try this:
ImageSnapshot.objects.filter(flight=flight, inspection__review_check=True)