-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Reduce queries for supported ManyRelatedField #9211
base: master
Are you sure you want to change the base?
Conversation
tests seems to be failing after new push, can you recheck please? |
cec275d
to
b72027f
Compare
It should be good now. There is also some general issues to talk about in the PR description :-) |
@auvipy What do you think about the pull request? Is there some ways I can improve it? |
what is the current standing of the issues now? is this backward compatible? and do you think all other related issues can be resolved in this PR? |
I think all issues should be fixed in this pull request but I am asking for some advice on the issues because I am not sure what is the best way of solving them.
|
Description
From the discussion here #8919, a related field with a
many=True
will only execute one query for all items instead of one for every item.It currently works for:
There are currently four issues regarding this pull request:
to_many_internal_value
and only overrideto_internal_value
, the overridden value won't be used (becauseto_many_internal_value
will be use instead).to_internal_value
property was overwritten and raise an error / use the old behaviour in this case but I am not sure this is a good ideaPrimaryKeyRelatedField
, when the type is wrong, the type of the first item is raised in the error as it is unclear how to retrieve the problematic item. Some solutions to keep the old behaviour if this is an issue:SlugRelatedField
, I add to annotate the related field to detect if an item does not exist and which one. I don't know if this is acceptable or not.