Django distinct query is still returning duplicates

If you want to select distinct values from a specific field then it is recommend to specify that field along with id in distinct that way it will be more precise

To put in code, the distinct in your case would more like be:

ShoppingItems.objects.filter(user=account, shoppingList=shoppingList, recipe__isnull=False).distinct('id', 'recipe').values('recipe')