In my models.py file I have:
class Place(models.NodeModel):
name = models.StringProperty()
class Person(models.NodeModel):
name = models.StringProperty()
age = models.IntegerProperty()
location = models.Relationship('self', rel_type='lives_in', related_name='place')
class Pet(models.NodeModel):
name = models.StringProperty()
owner = models.Relationship(Person,
rel_type='owns',
single=True,
related_name='pets'
)
Then I have an instance 'Pete' of the class Person:
neo4j-sh (Pete,2)$ ls
==> *age =[30]
==> *name =[Pete]
==> (me)-[:owns]->(Garfield,4)
==> (me)-[:lives_in]->(London,6)
==> (me)<-[:<<INSTANCE>>]-(mydb:Person,1)
I have no problems getting Pete's age and name, but I have trouble querying related entities.
For example, trying to get his location, I run
Person.objects.get(name='Pete').select_related('place')[0].name
but I got an error: AttributeError: 'Person' object has no attribute 'select_related'
Could you please tell me what I am doing wrong?