Querying nested objects in Django for OneToOneField
I have a data structure that looks like this (simplified version)
class A(models.Model):
a = models.IntegerField()
class B(models.Model):
c = models.OneToOneField(A)
Now, my question is, what kind of query do I have to perform so that I find all objects b of class B such tha开发者_如何转开发t b.c.a = 1?
Thanks.
That should be b = B.objects.filter(c__a=1)
.
精彩评论