﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3691	Telling Q Objects to split up foreign keys (extension of #3592)	axiak@…	Adrian Holovaty	"This is not a duplicate of #3592.

I was working with some of the things in #3592, and it seems from chatting on IRC that people really want a way to do ANDs on a m2m field without the Q objects subsuming them into one JOIN.

Example: 
Suppose you have Article and Tag, where Article has a m2m relation with Tag ({{{related_name = 'tag'}}}). If I run:
{{{
from django.db.models.query import Q
Article.objects.filter(Q(tag__value = 'A') & Q(tag__value = 'B'))
> # no results
}}}
I would expect to get no results (there are no tags with both a value of 'A' and 'B').
However, I *would* like to somehow get a list of articles with tags meeting that criteria. Using the patch, you can:
{{{
from django.db.models.query import Q,QSplit
Article.objects.filter(QSplit(Q(tag__value = 'A')) & QSplit(Q(tag__value = 'B'))) 
> # articles with both tags
}}}
So now they are ``split'' into different Tag entries.

This isn't meant to be used in django. Just for people if they need it before the queryset refactoring. Also, this seems like it would be useful in the final version, so it's here for reference."		closed	Database layer (models, ORM)	dev		duplicate	Q,QSplit,m2m		Unreviewed	1	0	0	0	0	0
