neo4django:意外(?)警告?

时间:2013-05-27 18:47:45

标签: django-models neo4j neo4django

我不确定为什么会收到此警告;我可能不完全理解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电流。

有什么想法吗?

1 个答案:

答案 0 :(得分: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'。

但是,我不确定证据警告。如果模特的工作方式如你所愿,我不会担心。