[Fixed]-Amend django-template if statement to ignore duplicates

1👍

Update for view based on comments. Try this:

show_presentation_list = []
menus_presentation = []

for menu in menus:
    if menu.mealtype and menu.mealtype not in show_presentation_list:
        show_presentation_list.append(menu.mealtype)
        menus_presentation.append(menu)

Also your new template, try this:

{% for menu in menus_presentation %}
    <li role="presentation">
            <a href="#tab{{forloop.counter}}" aria-controls="tab{{forloop.counter}}" role="tab" data-toggle="tab">{{menu.mealtype}}</a> 
    </li>
{% endfor %}

Leave a comment