1👍
I think this solve your problem:
def get_queryset(self):
groceries = Grocery.objets.filter(some_filter)
recipes = Recipe.objects.filter(pk__in=Ingredient.objects.filter(priority='high',grocery__in=groceries).values_list('recipe_id', flat=True).distinct())
Source:stackexchange.com