Reputation: 151
My nav pills appears in a single row. But once I add django template tags to it, the pills stacks on top of each another.
How do I fix it so that the pills appear all in one row?
Without django tags
<ul class="nav nav-pills">
<li role="presentation" class="active"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Messages</a></li>
</ul>
With django tags
{% for menu in menus %}
<ul class="nav nav-pills">
{% if menu.mealtype == 'Breakfast' %}
<li role="presentation" class="active"><a href="#">Home</a></li>
{% endif %}
{% if menu.mealtype == 'Lunch' %}
<li role="presentation"><a href="#">Profile</a></li>
{% endif %}
</ul>
{% endfor %}
Upvotes: 1
Views: 33
Reputation: 3974
Your problem is that your for loop {% for menu in menus %}
repeats the <ul>
tag as well. You are making a separate list per entry.
Try moving your for
loop inside the <ul>
tags.
<ul class="nav nav-pills">
{% for menu in menus %}
{% if menu.mealtype == 'Breakfast' %}
<li role="presentation" class="active"><a href="#">Home</a></li>
{% endif %}
{% if menu.mealtype == 'Lunch' %}
<li role="presentation"><a href="#">Profile</a></li>
{% endif %}
{% endfor %}
</ul>
Upvotes: 1