Question: I tried to look in other solutions. But it didn't help me out. Kindly look into this.
my html code.

```
<tbody>
  {% for st in stu %}
    <tr>
      <th scope="row">{{st.id}}</th>
      <td>{{st.name}}</td>
      <td>{{st.email}}</td>
      <td>{{st.role}}</td> 
      <td>
        <a href="{}" class="btn btn-warning btn-sm">Edit</a> {% csrf_token %}
        <form action="{% url 'deletedata' pk = st.id %}" method = "POST" class="d-inline"> {% csrf_token %}

        <input type="submit" class="btn btn-danger" value="Delete">
        </form>

      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>

```

my views.py and urls.py code

```
def delete_data(request,id): 
    if request.method == 'POST':
        pi = User.objects.get(pk=id)
        pi.delete()
        return HttpResponseRedirect('/')

urlpatterns=[
     re_path('delete/<int:pk>/',views.delete_data,name="deletedata")
]

```

Answer: 
Try this

In the template, you have used pk

change in the template or in view and url

```
urlpatterns=[
    re_path('<int:pk>/',views.update_data,name="deletedata")
]

```

Or

```
<form action="{% url 'deletedata' id = st.id %}" method = "POST" class="d-inline"> {% csrf_token %}

        <input type="submit" class="btn btn-danger" value="Delete">
        </form>

```
{% url 'deletedata' pk = st.id %}
in thr URL just remove the spaces, bellow code it should work

```
    <tbody>
  {% for st in stu %}
    <tr>
      <th scope="row">{{st.id}}</th>
      <td>{{st.name}}</td>
      <td>{{st.email}}</td>
      <td>{{st.role}}</td> 
      <td>
        <a href="{}" class="btn btn-warning btn-sm">Edit</a>
        <form action="{% url 'deletedata' pk=st.id %}" method = "POST" class="d-inline"> {% csrf_token %}

        <input type="submit" class="btn btn-danger" value="Delete">
        </form>

      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>

```