-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Check correct model on other side of many to many reverse filtering #2283
Check correct model on other side of many to many reverse filtering #2283
Conversation
Depending on the manager type there could be different model arguments. For a `ManyRelatedManager` the argument is the `through` model, but we want to check the `to` model. As a simple starter we stash the `to` model in the manager's metadata and set a precedence on fetching the `to` model from metadata.
other.mymodel_set.filter(xyz__isnull=True) # E: Cannot resolve keyword 'xyz' into field. Choices are: id, others [misc] | ||
other.mymodel_set.get(xyz__isnull=True) # E: Cannot resolve keyword 'xyz' into field. Choices are: id, others [misc] | ||
other.mymodel_set.exclude(xyz__isnull=True) # E: Cannot resolve keyword 'xyz' into field. Choices are: id, others [misc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually had incorrect tests for the issue fixed here .. 🙂
@sobolevn it might be a bunch of false negatives due to the issue here that will come from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix!
Co-authored-by: sobolevn <[email protected]>
Depending on the manager type there could be different model arguments. For a
ManyRelatedManager
the argument is thethrough
model, but we want to check theto
model.As a simple starter we stash the
to
model in the manager's metadata and set a precedence on fetching theto
model from metadata.Related issues
ManyToManyField
#2275