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

Encoding select_related #11

Open
lsemel opened this issue Jul 5, 2011 · 3 comments
Open

Encoding select_related #11

lsemel opened this issue Jul 5, 2011 · 3 comments

Comments

@lsemel
Copy link
Contributor

lsemel commented Jul 5, 2011

Is there a way to get encode_data to recognize models pulled in with select_related in the queryset passed to it?

@joestump
Copy link
Owner

joestump commented Jul 5, 2011

I hadn't even heard of select_related before you mentioned this, so I have no idea. What I do know is the expand option on encode_record will do what you're looking for for ForeignKey fields. This is one of the issues with the project: encode_data and encode_record behave somewhat differently.

I think what you'll want to do is loop over your QuerySet and use encode_record on each model instance rather than encode_data on the entire QuerySet. I think the DefaultEncoder, which should supersede the old encode_data/encode_record does this now.

@lsemel
Copy link
Contributor Author

lsemel commented Jul 5, 2011

I tried looping over them but it still doesn't pull in my model, which has a OneToOne relationship with the main one. Does it work with OneToOne models?

@joestump
Copy link
Owner

joestump commented Jul 5, 2011

Probably not. If you checked for both ForeignKey and OneToOne in this line of code, it might work:
https://github.com/joestump/django-ajax/blob/master/ajax/endpoints.py#L39

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