Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';我不理解在Django中使用through模型的查询做什么_Django_Django Models - Fatal编程技术网

Can';我不理解在Django中使用through模型的查询做什么

Can';我不理解在Django中使用through模型的查询做什么,django,django-models,Django,Django Models,我有以下型号: class Goal(Model): id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # title of the goal title = CharField(verbose_name=_('Name'), max_length=256) children = ManyToManyField('self', through='DecompositionG

我有以下型号:

class Goal(Model):
    id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False)

    # title of the goal
    title = CharField(verbose_name=_('Name'), max_length=256)

    children = ManyToManyField('self', through='DecompositionGoal', symmetrical=False)


class DecompositionGoal(Model):
    id = UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    parent = ForeignKey(Goal, related_name='related_src')
    child = ForeignKey(Goal, related_name='related_dst')

    is_accepted = BooleanField(default=False)
对于一个给定的目标,我试图找到所有被接受的儿童目标。 我最终得到了
goal.children.filter(related_dst_uuis_accepted=True)

但出于好奇,以下选项选择了什么:
goal.children.filter(related\u src\u\u is\u accepted=True)


有人能解释一下在使用through模型时所有这些工作吗?

因此,对于您的目标子节点,如果其父节点(原始目标)被接受,您将过滤掉它们,因此,如果父节点被接受,您将获得所有子节点,如果父节点不被接受,则无子节点