I have a view based on DeleteView that works perfectly if the user agrees to the deletion, but goes to the wrong URL if the user cancels the deletion. Is there a way to specify the cancel URL (similar to how I override get_success_url() to provide the URL if the user OKs the deletion)?
More detail: I have a Tune model, and each Tune can have one or more Scores. The code in question deletes a Score using URL tune/<int:pk>/delete_score (overriding the get_success_url method to get there). But when the user cancels the deletion, the user is sent to URL tune/<int:pk>/edit, which is wrong (and can’t be made right, because that URL is already used for another purpose: going to a tune without specifying the score).
Perhaps I should use an EditView instead, and delete the object in the form_valid method. This needs a bit more hand coding, but has the advantage that if I put up my own confirmation dialog box in response to clicking the delete button, I can do nothing if the user cancels – I will still be on the page that shows the delete button. Still…it has disadvantages, such as getting to the delete URL some other way will have no confirmation.