2

I'm iterating over multi modals using a for loop in django template but the modal worked only for the first element of the list. I've modified id values in <a href=...> and <div class="modal fade"> to change with the loop as suggested in Bootstrap modal, django for loop and model and multi modals bootstrap in for loop django. Still not working.

Any suggestions ? Here is a snippet of my code:

{% for sess in session %}        
   <a href="#{{ sess.id }}" role="button" class="btn btn-fix text-left p-0" data-toggle="modal">Link</a>
   <div class="modal fade" id="{{ sess.id }}" role="dialog">
         <div class="modal-dialog modal-lg">
             <div class="modal-content">
                     <h5>{{sess.Title}}</h5>
                     <p class="text-right">
                       <button type="button" class="btn btn-outline-dark btn-sm" data-dismiss="modal">Close</button>
                     </p>
             </div>
         </div>
   </div> 
{% endfor %}
Yassine
  • 189
  • 1
  • 1
  • 10

1 Answers1

2

I know why: The id value in the button & modal should not be anumber (so not {{sess.id}}). It's working with test{{sess.id}} though.

Yassine
  • 189
  • 1
  • 1
  • 10