#16172: Filtering queryset using Q objects to find objects with two specific values on the same many:many relationship returns 0 results -------------------------------------+------------------------------------- Reporter: | Owner: nobody mpdaugherty | Status: closed Type: Bug | Component: Database layer Milestone: | (models, ORM) Version: 1.3 | Severity: Normal Resolution: invalid | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs tests: 0 Needs documentation: 0 | Easy pickings: 0 Patch needs improvement: 0 | -------------------------------------+------------------------------------- Changes (by kmtracey):
* status: new => closed * needs_better_patch: => 0 * resolution: => invalid * needs_tests: => 0 * needs_docs: => 0 Comment: I believe the Q objects are doing what they are intended to do, it's just not the right way to approach what you are looking for. I believe the query you want is: {{{ A.objects.filter(tags__value__iexact='T1').filter(tags__value__iexact='T2') }}} (Changing the behavior the Q objects would be more than a performance drawback, it would change the results of the queries. There are use cases where their current behavior is what is needed, changing in the way you propose is not an option since that would break those valid use cases.) -- Ticket URL: <https://code.djangoproject.com/ticket/16172#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.