Django’s class based DeleteView directs the user to a confirm page before the item is deleted. If the user decides they do not want to delete, they can cancel it by clicking the back button on the browser. Pretty simple. Reinforces the meaning of the back button.
Some of my customers disagree with that line of thinking. When some users accidentally end up on the delete confirm page, they panic. They probably are not even thinking of using the back button. Moreover, they might not be confident that the back button does not do a delete before going back. A “Cancel” button is what they really want.
How to implement it with minimal hacking? The answer is almost too simple: add a Cancel button and have it’s onclick method issue a back command. Here is a Bootstrap template that does that:
<form action="" method="post"> <p>Are you sure you want to delete the item?</p> <input class="btn btn-primary" type="submit" value="Confirm"/> <button onclick="window.history.back();" class="btn btn-default" type="button">Cancel</button> </form>