I was going to file a ticket in trac about this and found this one( https://code.djangoproject.com/ticket/21192) which seems related. The thing is that one was supposedly resolved 5 weeks ago, which would mean that fix would be in 1.6rc1... Should I reopen that ticket or file a new one?
On Monday, November 4, 2013 3:46:04 PM UTC-2, Anssi Kääriäinen wrote: > > > > On Monday, November 4, 2013 7:24:47 PM UTC+2, jga...@gmail.com wrote: >> >> Anssi, >> >> Thanks for helping. >> I'm sorry to say that your answer went somewhat over my head, my >> proficiency with SQL is lacking. >> >> What I understood from your explanation: >> - A filter/exclude that traverses a 1:N relationship(such as foreign >> key) should target the same row with all of its criteria(kwargs). >> - Complex queries don't work correctly in exclude when using >> relationships in 1.5.x >> - Complex queries don't work correctly in exclude when using >> relationships in 1.6.x >> >> Did I understand correctly? >> > > That is a good summary of the situation, except that the exclude bugs are > about 1:N (or N:N) relationships, not just any relationship. > > >> If that was the whole of the situation I would be ok, I can work around >> this issue with multiple exclude statements, such as: >> bees = B.objects.exclude(a__confirmation=False, a__state=1) >> bees = bees.exclude(a__confirmation__isnull=True, a__state=1) >> That should be equivalent to what I was trying to do with: >> confirm_q = Q(a__confirmation=False) | Q(a__confirmation__isnull=True) >> bees = B.objects.exclude(confirm_q, a__state=1) >> >> But my solution of splitting the Q into two queries didn't work, for >> either 1.5.5 or 1.6rc1. >> Did I miss something? >> > > I'd go for a solution where you do: > a_qs = A.objects.filter(Q(confirmation__isnull=True) | ..., a__state = > 1).values_list('b_id') > bees = B.objects.exclude(pk__in=a_qs) > If I am not mistaken that is what Django should be doing automatically for > you. > > Seems like django-users is the right forum to continue this discussion > unless there are more items that are about development of Django itself. > > - Anssi > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2e67872c-043e-4733-a2a3-c62d55615aee%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.