我不确定为什么会收到此警告;我可能不完全理解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电流。
有什么想法吗?
答案 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'。