Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PierreVaillat opened this issue Jan 30, 2014 · 1 comment
Open

Comments

@PierreVaillat
Copy link

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...

@saswat01
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants