def getListIngredient(): all_ingr_list = [] ingr_list = [] ingredients = RecipeIngredient.getAllIngredients() recipe = ingredients[0].recipe_fk for ingr in ingredients: if ingr.recipe_fk == recipe: ingr_list.append(ingr.ingredient_name) else: recipe = ingr.recipe_fk all_ingr_list.append(ingr_list) ingr_list = [ingr.ingredient_name] print "ALL_LIST", all_ingr_list return all_ingr_list