通过 Django 中的相同中间模型与同一模型的两个 ManyToMany 关系

Two ManyToMany relations to the same model via the same intermediate model in Django

我的模特:

class Person(SchoolModel):
    first_name = models.CharField(max_length=75)
    last_surname = models.CharField(max_length=75)

    students = models.ManyToManyField('self', through='StudentParent',
        through_fields=('parent', 'student'), related_name='+')
    parents = models.ManyToManyField('self', through='StudentParent',
        through_fields=('student', 'parent'), related_name='+')


class StudentParent(SchoolModel):
    student = models.ForeignKey('Person')
    parent = models.ForeignKey('Person')
    relation = models.CharField(max_length=26)

    class Meta:
        unique_together = ('student', 'parent')

如上所示,Person 模型与自身有两个 m2m 关系:students 和 parents。每个人在同一个人table上可能有很多学生,也可能有很多parents。

但是,Django 不允许这样做:

Person: (models.E003) The model has two many-to-many relations through  
the intermediate model 'StudentParent'.

我不明白为什么 Django 拒绝这样做,特别是因为它不使用自定义中介 tables 保存或验证 m2m 字段。另一方面,我只需要使用这些字段就可以更轻松地检索相关模型。示例:

person_obj.students.all()
Person.objects.filter(parents__in=another_person_queryset)

所以我的问题是,1) Django1.11 中是否有解决此问题的方法(通过配置等使这样的 2 个 m2m 字段成为可能)? 2) 有没有办法通过其他方式使只读方案发生这种情况?

使用中介模型的代理会欺骗 django 来实现 1) 吗? 使用自定义管理器是否有助于实现 2)?最短、最整洁的路径是什么?

注意: 我知道之前有人问过类似的 question,但是有点不同而且有点旧。

似乎通过代理模型欺骗 Django 可以达到我上面描述的目的(检索模型实例的相关数据或在过滤查询集中)。所以模型变成:

class Person(SchoolModel):
    first_name = models.CharField(max_length=75)
    last_surname = models.CharField(max_length=75)

    students = models.ManyToManyField('self', through='StudentParentProxy', # << !!!!!!
        through_fields=('parent', 'student'), related_name='+')
    parents = models.ManyToManyField('self', through='StudentParent',
        through_fields=('student', 'parent'), related_name='+')


class StudentParent(SchoolModel):
    student = models.ForeignKey('Person')
    parent = models.ForeignKey('Person')
    relation = models.CharField(max_length=26)

    class Meta:
        unique_together = ('student', 'parent')


class StudentParentProxy(StudentParent):
    class Meta:
        proxy = True  # << !!!!!!