Re: Get all objects that don't belong to M2M

2013-03-08 Thread galgal
I think that did the trick: *Product.objects.filter(subproducts__isnull=True)* On Friday, March 8, 2013 1:50:47 PM UTC+1, Martin J. Laubach wrote: > > Something like this (totally untested though) > > Product.objects.exclude(pk__in=Product.subproducts.through.values_list( > 'product_id', flat=Tru

Re: Get all objects that don't belong to M2M

2013-03-08 Thread Martin J. Laubach
Something like this (totally untested though) Product.objects.exclude(pk__in=Product.subproducts.through.values_list( 'product_id', flat=True)) perhaps? Cheers, mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe fr

Get all objects that don't belong to M2M

2013-03-08 Thread galgal
I have a model with field: class Product(models.Model): subproducts = models.ManyToManyField("self", blank=True) I need to overwrite admin's field queryset, to display only that objects that don't belong to any m2m relation. I have no idea how to get them. So if I have: product1, product2