The problem is that querying across manytomany relationships gives you an effective join. Hence the duplication. This makes perfect sense from an SQL point of view but from an ORM point of view (i.e. Nodes.objects.filter()), it's a bit weird, I'll give you that.
> Woops, needs a unique! Thanks for spotting.
It needs a unique indeed. But it has nothing to do with the union: paste.ubuntu. com/8803036/ (fwiw, this is the query this generates http:// paste.ubuntu. com/8803039/).
This is a way to trigger the problem: http://
The problem is that querying across manytomany relationships gives you an effective join. Hence the duplication. This makes perfect sense from an SQL point of view but from an ORM point of view (i.e. Nodes.objects. filter( )), it's a bit weird, I'll give you that.
Also, you can make the code is a tad nicer: http:// paste.ubuntu. com/8803384/