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
[django] Do not generate warning for (un)needed prefetch_related
on get
#10
Comments
Checking in the code, I think that not only I still don't know in your code how to ignore relations that are not FK or OneToOne for |
Good point. One option might be to ignore queries that return a single result, like Does that make sense? I can try it out soon. |
|
I really tried to do something but I didn't succeed to have a full vision of what the code is doing :) |
I started working on this in #11. |
I just saw you merged your work. I'll try as soon as Tuesday ! Thanks a lot! |
It seems ok, I close the issue :) Fixed in #11 |
Hello.
I love the idea of this app. Wanted this/to create it for years. So, thank you.
One thing that annoy me a little is this: in the test
test_many_to_one_reverse
,nplusone
generates a warning when selecting addresses for a user.But I don't think it should, as doing a
prefetch_related
here won't change anything: we'll still have two queries, one to get the first user, and one to get the addresses (instantly if we useprefetch_related
, and only when asking for addreses when not)Sadly this prevents me to really use this lib because it can happens a lot as there is no optimization to do here, so nobody does a
prefetch_related
for aget
(or.first()
too?).Think of edit forms, detail views...
The only way to change this would be to monkey patch the
get
method, to not take the current queryset into action for missingprefetch_related
(but still do for missingselect_related
).The text was updated successfully, but these errors were encountered: