Jul-12-2020, 02:56 PM
I could make it in the following way, but I know that this is the longest solution, for sure there is a better way, but as a student it's ok. If anybody has a better idea, please share it thank you.
<select id="category" name="category_name"> {% if recipe.category_name == "pasta" %} <option value="pasta" selected>Pasta</option> {% else %} <option value="pasta">Pasta</option> {% endif %} {% if recipe.category_name == "meatfish" %} <option value="meatfish" selected>Meat&Fish</option> {% else %} <option value="meatfish">Meat&Fish</option> {% endif %} {% if recipe.category_name == "vegetarian" %} <option value="vegetarian" selected>Vegetarian</option> {% else %} <option value="vegetarian">Vegetarian</option> {% endif %} {% if recipe.category_name == "dessert" %} <option value="dessert" selected>Dessert</option> {% else %} <option value="dessert">Dessert</option> {% endif %} {% if recipe.category_name == "baking" %} <option value="baking" selected>Baking</option> {% else %} <option value="baking">Baking</option> {% endif %} </select>