Ben2pop
Ben2pop

Reputation: 756

Using django tag in a div ID

I am trying to generate dynamically an ID in my app using bootstrap dropdown menu but for some reason it does not appear ..

<div class="dropdown">
  <button class="btn btn-secondary btn-sm btn-canvas dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Compare with
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    {% for i in team_list_pop %}
      <a class="dropdown-item" id="{{i.first_name}}" href="#">{{i.first_name}} {{i.last_name}}</a>
    {% endfor %}
  </div>
</div>

and the output when I do inspect in my browser

<a class="dropdown-item" href="#">John Doe</a> 

with no traces of the ID. how can I get to hve an output

<a id="john" class="dropdown-item" href="#">John Doe</a>

thx you very much

Upvotes: 0

Views: 68

Answers (1)

Alessio Ferri
Alessio Ferri

Reputation: 345

I think you should look if the value you are typing exit because i'm doing the same thing in my code and it worked:

... id="{{ values.0.vat }}" onclick="callAjax.call(this)" ...

This is an example code that i've used in one of my project and it correctly show the id in inspect.

Upvotes: 1

Related Questions