1

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?

user3241376
  • 407
  • 7
  • 20
  • I don't know the issue, but it looks someone else has same problem also. https://github.com/scholrly/neo4django/issues/237 – nikolasd May 08 '14 at 20:01
  • yep ,I've seen this post as well. I've searched for hours everywhere on the net before asking here.. – user3241376 May 08 '14 at 21:29

0 Answers0