title: How to do Delete confirmation for a table data with bootstrap Modal in Django?
body: <p>I'm having a table to show a list of actions in my app. I can delete any action in that table. So, I have added a delete button in every row. This delete button will trigger a 'delete confirmation' bootstrap modal.</p>
  
  <pre><code>&lt;table class="table table-hover"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th scope="col"&gt;#&lt;/th&gt;
        &lt;th scope="col" class="th-lg"&gt;Name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    {% for action in actions_list %}
    &lt;tbody&gt;
      &lt;tr class="test"&gt;
        &lt;th scope="row" class="align-middle"&gt;{{ forloop.counter }}&lt;/th&gt;
        &lt;td class="align-middle"&gt;
          {{action.action_name}}
        &lt;/td&gt;
        &lt;td class="align-middle"&gt;
          {{action.id}}
        &lt;/td&gt;
        &lt;td&gt;
          &lt;div class="row justify-content-end"&gt;
            &lt;button
              id="edit"
              type="button"
              class="btn btn-sm btn-dark col col-lg-2"
              style="color: rgb(255,0,0,0)"
            &gt;
              &lt;i class="lni-pencil"&gt;&lt;/i&gt;
            &lt;/button&gt;
            &lt;button
              id="trash"
              type="button"
              class="btn btn-sm btn-dark col col-lg-2"
              style="color: rgb(255,0,0,0)"
              data-toggle="modal"
              data-target="#modalConfirmDelete"
            &gt;
              &lt;i class="lni-trash"&gt;&lt;/i&gt;
            &lt;/button&gt;
          &lt;/div&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
    {% endfor %}
  &lt;/table&gt;
  </code></pre>
  
  <p>Below is the code for 'Delete Confirmation' bootstrap modal. It will have 'Yes' and 'No' buttons.
  If I click 'Yes', then that particular action id will be passed to URL and that particular action id will be deleted.</p>
  
  <pre><code>{% block modalcontent %}
  
  &lt;!--Modal: modalConfirmDelete--&gt;
  &lt;div
    class="modal fade"
    id="modalConfirmDelete"
    tabindex="-1"
    role="dialog"
    aria-labelledby="exampleModalLabel"
    aria-hidden="true"
  &gt;
    &lt;div class="modal-dialog modal-sm modal-notify modal-danger" role="document"&gt;
      &lt;!--Content--&gt;
      &lt;div class="modal-content text-center"&gt;
        &lt;!--Header--&gt;
        &lt;div class="modal-header d-flex justify-content-center"&gt;
          &lt;p class="heading"&gt;Are you sure?&lt;/p&gt;
        &lt;/div&gt;
  
        &lt;!--Body--&gt;
        &lt;div class="modal-body"&gt;
          &lt;i class="fas fa-times fa-4x animated rotateIn"&gt;&lt;/i&gt;
        &lt;/div&gt;
  
        &lt;!--Footer--&gt;
        &lt;div class="modal-footer flex-center"&gt;
          &lt;form action="{% url 'delete_action' aid=action.id %}"&gt;
            {% csrf_token %}
            &lt;button class="btn  btn-outline-danger"&gt;Yes&lt;/button&gt;
          &lt;/form&gt;
  
          &lt;a
            type="button"
            class="btn  btn-danger waves-effect"
            data-dismiss="modal"
            &gt;No&lt;/a
          &gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;!--/.Content--&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>In above code, I'm using a <strong>form</strong> tag for the delete action then that action id URL will trigger.</p>
  
  <p>Below is the URL to delete an action,</p>
  
  <pre><code>re_path(r'^delete_action/(?P&lt;aid&gt;\d+)/',
              views.delete_action, name='delete_action')
  </code></pre>
  
  <p><strong>Problem I'm Facing</strong> :
  I need action.id value in the modal which I'm not getting!</p>
  
  <p>Please help me to solve this. thanks in advance :)</p>