[Django]-Filter on ManyToManyField intermediate table fields

8👍

Here –

items = Item.objects.filter(customer_items__customer=customer, customer_items__item_count__gt = 0)

As you’ve added related_name='customer_items' to the Item foreign-key. You can access the CustomerItem related to any Item via item.customer_items. Rest is piece of cake.

2👍

what about this?

Customer.object.filter(customeritem__item_count__gt=0)

Leave a comment