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: 
You are using `re_path` like it is `path`. `re_path` expects regex, it does not have path converters like `path`. You can either write a regex or switch to `path`.  

Regex solution:

```
urlpatterns=[
    re_path(r'delete/(?P<pk>\d+)/',views.delete_data,name="deletedata")
]

```

path solution:

```
from django.urls import path

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

```

**Edit:** Also in your view you have named your parameter as **id**, all captured arguments from the url pattern are passed as keyword arguments, ensure that your naming is **consistent** in your pattern, view, template.  

Change your view definition (and all usages of the variable in the view function to **pk**) to:

```
def delete_data(request, pk):

```
{% 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>

```