Hi,

I have the following models: Abonnent -1:n- Sendungsadresse -1:1- Redresse
Model `Abonnent` has 99681 rows.

This query returns 829 rows, as expected:
    `Abonnent.objects.filter(sendungsadresse__redresse__isnull=False, 
sendungsadresse__redresse__korrigiert_am__isnull=True).distinct()`

The second query returns 98852 rows, as expected:
    
`Abonnent.objects.all().difference(Abonnent.objects.filter(sendungsadresse__redresse__isnull=False,
 
sendungsadresse__redresse__korrigiert_am__isnull=True).distinct())`

But I want to be able to keep filtering and that does not work with 
difference().
So I created this query, that returns 98851 rows, when I was expecting 
99852 rows:
    `Abonnent.objects.exclude(sendungsadresse__redresse__isnull=False, 
sendungsadresse__redresse__korrigiert_am__isnull=True)`

The missing Abonnent object in that query has two Sendungsadresse objects. 
The following statements are true for each corresponding Sendungsadresse 
object, but neither of them should be excluded, unless I am missing some 
peculiarity about exclude() (which I probably am, to be honest):
    Object 1: redresse__isnull => True,  redresse__korrigiert_am__isnull => 
True
    Object 2: redresse__isnull => False, redresse__korrigiert_am__isnull => 
False

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1644468c-b3d3-4f53-8d99-49348a59a9e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to