scholrly / neo4django

Drop-in Neo4j/Django integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError : 'Person' object has no attribute 'select_related'

PierreVaillat opened this issue · comments

Hi,

First of all, implementing neo4j with the Django framework is a great initiative. Bravo !

Unfortunately, I have tried to replicate your example and am experiencing some difficulties while trying to fetch the related objects.

jack = Person.objects.get(name='jack')
jack.select_related()
AttributeError : 'Person' object has no attribute 'select_related'

When examining the source, I realized that, indeed, the only select_related() method is related to the NodeQuerySet class, which I hoped to call from the objects attribute of the instance (e.g. "jack"). This gives

jack.objects.select_related()
AttributeError: Manager isn't accessible via Person instances

Okay... Then I try :
Person.objects.select_related()
and it behaves like Person.objects.all(), not really what I expected... :-(

Of course, I also tried
Person.objects.get(name='jack').select_related()
in vain... (same missing attribute as the first error mentionned).

So, I'm lost trying to use the most promising feature. It's frustrating :-) !

Could you help me, please ?

P.S. : By the way, shouldn't it be "models.Relationship('self'...)" instead of "Relationship" in the Docs ? :
class FamilyPerson(Person):
parents = Relationship('self', rel_type='child_of')

Moreover, the rel_single argument is rejected.

So, could it be version matter ? I'm using neo4django 0.1.8 with Neo4j-community 1.9.3 and django 1.5.5 (Python 2.7.6 on Ubuntu),

P.S2 : I am puzzled to find that I am the only one to raise this problem. I must have missed something big... but could not see anything...

When attribute error like this occurs you should make it a global variable in case you are calling from method. If it is not a method that you are calling and maybe a class under which you operate add self.whatever(whatever you want to act upon)

Hope it does all.