﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33587	Improve SuccessMessageMixin working with BaseDeleteView	Chris Chapman	Dulalet	"Currently a developer is blocked from easily using values from the object before deleting it. This is because `BaseDeleteView.form_valid` is where the object is deleted, but this is called before constructing the success message. This could be easily improved if `SuccessMessageMixin.form_valid` method was slightly modified. The following suggestion just switches the order of the first two lines in the method:

{{{
    def form_valid(self, form):
        success_message = self.get_success_message(form.cleaned_data)
        response = super().form_valid(form)
        if success_message:
            messages.success(self.request, success_message)
        return response

}}}

This change would allow the following to work:
{{{
MyDeleteView(SuccessMessageMixin, DeleteView):
    """"""Delete object and give user feedback on success.""""""
    
    success_message = ""Successfully deleted %(name)s""
    ...

    def get_success_message(self, cleaned_data):
        data = {**cleaned_data, ""name"": str(self.object)}
        return super().get_success_message(data)
}}}

Just as before, the message will only be applied if the call to `super().form_valid(form)` is successful. 
This change would allow access to the object as typically expected with any class inheriting from `SingleObjectMixin`. 

"	Bug	closed	contrib.messages	4.0	Normal	wontfix			Unreviewed	0	0	0	0	0	0
