开发者

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜