2

我不确定为什么会收到此警告;很可能是我不完全理解这个related_name概念,但我认为不同rel_types会使上述模型不模棱两可/冲突......

我在 neo4django 中收到以下警告:

>>> from evidences.models import *
/[...]/neo4django/db/models/relationships.py:180: UserWarning: `evidence` and `evidence` share a relationship type and direction. Is this what you meant to do?
  % (r.name, name))
/[...]/neo4django/db/models/relationships.py:180: UserWarning: `families` and `families` share a relationship type and direction. Is this what you meant to do?
  % (r.name, name))

相关模型可以在这里找到:https ://gist.github.com/szabi/e57f23d76b885d604a36

我认为关系类型目标模型在具有相同related_name.

使用 Django 1.4,来自 git 的 neo4django 当前。

有任何想法吗?

4

1 回答 1

3

之间肯定有冲突

spouses = models.Relationship('Person',rel_type='SPOUSE',related_name='families')

children = models.Relationship('Person',rel_type='CHILD',related_name='families')

设置related_name表示您希望通过该名称访问关系另一端的模型实例。由于两条线都指向Person,因此每个 Person 实例都需要以某种方式确定families关系字段是指“SPOUSE”还是“CHILD”类型的 rel。

不过,我不确定证据警告。如果模型按照您的预期工作,我不会担心。

于 2013-05-28T00:41:30.423 回答