-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Support select_related and prefetch_related for inherited models and custom queryset for child models #531
base: master
Are you sure you want to change the base?
Conversation
Hi! Thank you for your commits! =) But if I use select_polymorphic_related without select_related everything working fine and vice versa If I use select_related without select_polymorphic_related in one query everything working good as well. I've sent you additional info in telegram :) |
Now all is great 🙌🏻 Ive tested select_related and select_prefetch_related together and also separatly and did not manage to find any duplicates in queries and so far so good. |
Anything holding this back? Feels like it would be a big win if it "just works" |
it would be really really nice to have this |
Hey team, when can we expect to get this merged? |
Thanks a lot for this PR. It single-handedly solved the biggest performance issue in my production app. |
implement support for a single query for select related base fetches across polymorphic models. adds a polymorphic QuerySet Mixin to enable non polymorphic models to fetch related models. Fixes: jazzband#198 jazzband#436 jazzband#359 jazzband#244 Possible Fixes: jazzband#498: support for prefetch_related cannot fetch attributes not on all child models or via class names Related: jazzband#531
implement support for a single query for select related base fetches across polymorphic models. adds a polymorphic QuerySet Mixin to enable non polymorphic models to fetch related models. fixes: jazzband#198 jazzband#436 jazzband#359 jazzband#244 possible fixes: jazzband#498: support for prefetch_related cannot fetch attributes not on all child models or via class names related: jazzband#531
I created a Gist showing how to use this enhancement without having to pin this PR version or modify Django Polymorphic: I haven't gotten to do extensive testing on it so anyone using it finding issues please let me know |
implement support for a single query for select related base fetches across polymorphic models. adds a polymorphic QuerySet Mixin to enable non polymorphic models to fetch related models. fixes: jazzband#198 jazzband#436 jazzband#359 jazzband#244 possible fixes: jazzband#498: support for prefetch_related cannot fetch attributes not on all child models or via class names related: jazzband#531
implement support for a single query for select related base fetches across polymorphic models. adds a polymorphic QuerySet Mixin to enable non polymorphic models to fetch related models. fixes: jazzband#198 jazzband#436 jazzband#359 jazzband#244 possible fixes: jazzband#498: support for prefetch_related cannot fetch attributes not on all child models or via class names related: jazzband#531
implement support for a single query for select related base fetches across polymorphic models. adds a polymorphic QuerySet Mixin to enable non polymorphic models to fetch related models. fixes: jazzband#198 jazzband#436 jazzband#359 jazzband#244 possible fixes: jazzband#498: support for prefetch_related cannot fetch attributes not on all child models or via class names related: jazzband#531
add
select_polymorphic_related
,prefetch_polymorphic_related
andcustom_queryset
methods for select and prefetch on inherited modelsTriggers Django errors when that field doesn't exist in a particular subclass
Example works exactly same as django select_related and prefetch_related