A simple distinct inner join in Django
Oct. 12th, 2010 01:47 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Let's say I have ColorProperty and DWThemeColor (which is the through of a ManyToMany between DWTheme and ColorProperty). And I want to get all distinct ColorProperties that belong to DWThemes. This is how:
You don't even want to know how long it took me to figure this out, people.
ColorProperty.objects.filter(dwthemecolor__isnull = False).distinct()
You don't even want to know how long it took me to figure this out, people.