[Django]-Django – delete button is not redirecting to the correct path

2👍

urls.py:

from django.urls import path
from . import views
urlpatterns = [
    path('', views.home, name="home"),
    path('delete/<int:list_id>/', views.delete, name="delete"),
]

You need to specify the int type in the url.

And also the trailing /

1👍

You need a regular expression to say a number is coming

path('delete/(?P<list_id>)[\d]+)/$', views.delete, name="delete"),

Leave a comment