404 error : no comment matches the given query
I've searched enough about this problem, but haven't been able to find a solution.
Please help me.
View.py
class comment_delete(DeleteView):
model = Comment
success_url = reverse_lazy('board_list.html')
urls.py
path('', views.home, name="home"),
path('board/', views.board.as_view(), name="board"),
path('board/<int:pk>/', views.board_detail.as_view(), name="board_detail"),
path('board_write/', views.board_write, name="board_write"),
path('board_insert', views.board_insert.as_view(), name="board_insert"),
path('board_edit/', views.board_edit, name="board_edit"),
path('board_update/', views.board_update, name="board_update"),
path('board_delete/', views.board_delete, name="board_delete"),
####### comment #########
path('board/comment/update/', views.comment_update, name="comment_update"),
path('board/<int:pk>/comment/<int:id>/delete/', views.comment_delete.as_view(), name="comment_delete")
comment.html
<form action="{% url 'comment_delete' pk=i.Board_id id=i.id %}" method='POST'>
Unless specified otherwise the delete view except only the pk from the object you want to delete so in your case that would be the comment :
path('board/comment/<int:pk>/delete/', views.comment_delete.as_view(), name="comment_delete")
Last thing, what is i.Board_id
and id.id
? When using variable be the most explicit, do name your variables in lower case as well.