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

select_related doesn't work... #450

Open
ghost opened this issue Mar 2, 2012 · 4 comments
Open

select_related doesn't work... #450

ghost opened this issue Mar 2, 2012 · 4 comments
Milestone

Comments

@ghost
Copy link

ghost commented Mar 2, 2012

I'm a newbie for django and mongoengine..
so I'm not sure my code is correct on this issue..

class Example(Document):
    member = ReferenceField(Members)

query = Example.objects().select_related(max_depth=0)

should not query variable have member field? so that when I code

query.member.name ---> None

but the result would be the member's name like Simson..

In my real application, I don't want to use dereference.. even though the class(Document) has ReferenceField
nor I want to use "only()", "exclude" methods..

How can I make mongoengine not use dereference even though the class(Document) has its own ReferenceField?

(I just implemented ReferenceField for the future so as to use it one day.. but not now)

@rozza
Copy link

rozza commented Mar 5, 2012

To do this just provide a string for the object id and don't use ReferenceField - at the top level they will always dereference.

@rozza rozza closed this as completed Mar 5, 2012
@rozza rozza reopened this Mar 5, 2012
@rozza
Copy link

rozza commented Mar 5, 2012

Perhaps a lazy flag for the future (default to true).

@ghost
Copy link
Author

ghost commented Mar 5, 2012

oh~~ "at the top level they will always dereference" !!!
oh~~~~

@rozza
Copy link

rozza commented Mar 5, 2012

Yeah, the aim was to stop all individual ReferenceFields racking up queries... But you removing all control over that is also bad.

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

1 participant