i want to delete a task from the database so i use this code this is my delete view
def task_Delete(request,id=None):
if request.method == \'POST\':
There are various problems in your code (for example the TaskForm
is not needed at all) however if you change the line
id = int(request.POST.get('task.id'))
to
id = int(request.POST.get('task_id'))
the object will probably be deleted; remember that the request parameter's name will be the same as the name
of the input (task_id
). I recommend using proper CBVs (a DeleteView
) for what you want to do - if you want a slow and comprehensive tutorial on that I recommend this article: https://spapas.github.io/2018/03/19/comprehensive-django-cbv-guide/