Reputation: 113
Lets say that i have 2 models :
Class OrderEvent(models.Model):
isPaid = models.Booleanfield()
Class Participant(models.Model):
orderEvent = models.ForeignKey(OrderEvent)
participantFirstName = models.CharField()
participantLastName = models.CharField()
#etc...
And i want to get all the participants where Orderevent.isPaid = True.
I think that i struggle to do something very simple...
Upvotes: 0
Views: 89
Reputation: 363
It is very simple;
Participant.objects.filter(orderEvent__isPaid=True)
As a suggestion you can follow,
naming conventions from here.
Django making queries from here.
Upvotes: 3