I would like you to teach me with django-drf.
There are django models for rooms, students in rooms, childs, parents of childs.
Class Room(models.model):
room_cd = models.IntegerField()
Class Student(models.model):
score = models.IntegerField()
model_room= models.ForeignKey(Room)
model_child = models.ForeignKey(Child)
Class Child(models.model):
child_name = models.CharField()
model_parent = models.ForeignKey(Parent)
Class Parent(models.model):
parent_name = models.CharField()
I want to extract the children whose parent is ‘kenny’ in the room ‘a100’.
There may be more than one child.
sql is this.
select * from Room As R
inner join Student As S on S.model_room = R.id
inner join Child As C on C.model_student = S.id
inner join Parent As P on C.model_parent = P.id
where R.room_cd = 'a100' and P.parent_name = 'kenny'
What would the code look like in django-drf?