I have the following Django models:
class Pa(models.Model):
pa_name = models.CharField
class Pb(models.Model):
pa = models.ForeignKey(Pa, related_name="pbs")
pb_name = models.CharField()
class Pc(models.Model):
pb = models.ForeignKey(Pb, related_name="pcs")
pc_name = models.CharField()
The queryset of Pc has this structure:
[
{ "id": 1,
"pc_name": "pc_1",
"pb" = {
"id": 10,
"pb_name": "pb_1",
"pa" : {
"pa_name" : "pa_1" # <-- How to filter queryset by pa_name attribute?
}
}
},
{ "id": 2,
"pc_name": "pc_2",
"pb" = {
"id": 20,
"pb_name": "pb_2",
"pa" : {
"pa_name" : "pa_2"
}
}
},
# ...
]
I'd like to return all those Pcs, where pa_name is "pa_1", i.e. filter over the 2. level nested object.