scholrly/neo4django — Issue #42: Relationship querying doesn't respect direction
Author: mhluongo
Created: 2011-12-10 04:24:54+00:00
State: open

Eg,

class L(models.NodeModel):
name = models.StringProperty()

class M(models.NodeModel):
name = models.StringProperty()
rel = models.Relationship(L, rel_type='related_to')

class N(models.NodeModel):
name = models.StringProperty()
rel = models.Relationship(M, rel_type='related_to')

>>> el = L.objects.create(name='LLL')
>>> m = M.objects.create(name='MMM')
>>> m.rel.add(el)
>>> m.save()
>>> n = N.objects.create(name='NNN')
>>> n.rel.add(m)
>>> n.save()
>>> list(o.name for o in m.rel.all())
['LLL','NNN']
>>> list(n.name for n in m.n_set.all())
['LLL','NNN']