I would like to run for loop to each of li tag and want to add content dynamically from django backend admin

I have created a navbar and content can be added from the backend but only the home nav bar shows the icon and the other navbar name is with the same icon. I want to add a different nav bar with a different icon. and want to run if, elif and else condition. please help me how to use if elif and else dynamically.

initial HTML without dynamic content

<!-- Nav Links -->
      <li class="nav-item">
        <a class="nav-link fs-5" href="#समाचार">
          <i class="fas fa-address-book mr-1">
          </i>समाचार
        </a>
      </li>
      <li class="nav-item active">
        <a class="nav-link fs-5" href="/">
          <i class="fas fa-home mr-1"></i>
          होमपेज
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link fs-5" href="#भिडियो">
          <i class="far fa-clone mr-1">
          </i>भिडियो
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link fs-5" href="#विजनेस">
          <i class="far fa-calendar-alt mr-1">
          </i>विजनेस
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link fs-5" href="#ग्यालरी">
          <i class="far fa-chart-bar mr-1">
          </i>ग्यालरी
        </a>
      </li>
      <li class="nav-item">
        <a class="nav-link fs-5" href="#प्रोफाइल">
          <i class="far fa-copy mr-1">
          </i>प्रोफाइल
        </a>
      </li>

Dynamic backend added HTML which suppose to change in order to work:

{% for i in nav_data %}
      {% if forloop.first %}  
      <li class="nav-item active">
        <a class="nav-link fs-5" href="/">
          <i class="fas fa-home mr-1"></i>
          {{i.name}}
        </a>
      </li>
      {% elif forloop.first %}
      <a class="nav-link fs-5" href="/">
        <i class="fas fa-home mr-1"></i>
        {{i.name}}
      </a>
      {% else %} 
      <li class="nav-item">
        <a class="nav-link fs-5" href="#भिडियो">
          <i class="far fa-clone mr-1">
          </i>{{i.name}}
        </a>
      </li>
      {% endif %}
      {% endfor %}

*Note: need to use if, elif and else condition in each li and i.name should give value from backend in ascending order.

Hi, if you want dynamic navbar links configured in the Admin, it would make sense to store all the data for them in your model.

This means the title, icon and URL. Then you could have just the forloop without extra branches to create these items.

Since you are using FA for the icons, you can store icon as CharField and then output this for the class for the navbar items.

Something like this:

<li class="nav-item">
        <a class="nav-link fs-5" href="{{ item.url }}">
          <i class="far {{ item.fa_icon }} mr-1"></i>
         {{ item.name }}
        </a>
</li>