A short snippet that will delete records from the database. The deletion will occur when you visit the
delete_id/somenumber/ url (defined inside urls.py), which will trigger the
delete_view function (also defined inside urls.py), delete the record from the database (forms.py) and redirect to the
/redirect-url/ (defined inside views.py).
Add an url: urls.py
Create a view that will delete the record: views.py
def delete_view(request, id_to_delete): ModelName.objects.filter(pk=id_to_delete).delete() return HttpResponseRedirect("/redirect-url/")