具有多个M2M的Django查询集?

时间:2016-02-19 14:54:15

标签: python django

class Node(models.Model):
    # ...  

class Zone(models.Model):
    nodes = models.ManyToManyField(Node)

class BusLine(models.Model):
    zones = models.ManyToManyField(Zone)

class Service(models.Model):
    bus_lines = models.ManyToManyField(BusLine)

如何获得与与ONE服务相关的总线相关的区域相关的所有节点?

1 个答案:

答案 0 :(得分:0)

Node.objects.filter(zone__busline__service=my_service)