-
Notifications
You must be signed in to change notification settings - Fork 173
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
Feature request: Allow AND operator to work with M2M relationship #144
Comments
I am also getting the same issue with M2M fieds |
Could either of you contribute a failing test case to our test project & test cases? It will make fixing it much easier 🙏 |
I'm working on building out a test case in your test suite for this issue but the gist of it that I can see is that when you use example from my test system:
UPDATE: I see what the issue is, this is creating a Q object that is looking for a single relation where the name is foo and bar at the same time, that is why this doesn't work. In order to handle this scenario the way I found to do it is that it needs chained filters for each condition: User.objects.filter( this ensures both attributes exist individually. Here is an example of the issue: |
Sorry just got back to this. Let me know if this PR covers what you want #174 |
Thank you for submitting the test @curtisstpierre, it clarifies what is requested, so I've now labelled the issue as an "enhancement". We could add validation to prevent many-to-many fields to be accidentally used in this way while not fully implemented. To fully support M2M field operations like the ones described above, we'd need to:
I don't think I'll have time to work on this any time soon. That said, contributions are more than welcome |
With a simple model like this, I can't filter Articles with tag "Cars" AND "Lamborghini"
The text was updated successfully, but these errors were encountered: