Question

I'm not sure why I get this warning; it might well be that I do not completely comprehend the related_name concept, but I thought having different rel_types would make the above model not ambiguous/conflicting...

I get the following warnings in 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))

The related model can be found here: https://gist.github.com/szabi/e57f23d76b885d604a36

I think that neither relationship type nor target model is shared between the relationships with the same related_name.

Using Django 1.4, neo4django current from git.

Any ideas?

Was it helpful?

Solution

There's definitely a conflict between

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

and

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

Setting related_name signifies that you want model instances on the other end of the relationship to be accessed by that name. Since both lines are pointing to Person, every Person instance would need to somehow figure out if the families relationship field refers to rels of type 'SPOUSE' or 'CHILD'.

I'm not sure about the evidence warning, though. If the models are working how you expect, I wouldn't worry about it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top