﻿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
35850	Default success messages for CreateView/UpdateView/DeleteView/...	Willem Van Onsem		"Hi,

I'm wondering if it would make sense to provide default success messages for the `CreatView`/`UpdateView`/`DeleteView` that will *not* be enabled as long as the `SuccessMessageMixin` is not enabled, but are when that is the case.

In order to do that we would have to split the `SuccessMessageMixin` to trick the MRO in overriding the message. So that would look like:

{{{
class BaseSuccessMessageMixin:
    success_message = """"


class SuccessMessageMixin(BaseSuccessMessageMixin):
    """"""
    Add a success message on successful form submission.
    """"""

    def form_valid(self, form):
        response = super().form_valid(form)
        success_message = self.get_success_message(form.cleaned_data)
        if success_message:
            messages.success(self.request, success_message)
        return response

    def get_success_message(self, cleaned_data):
        return self.success_message % cleaned_data
}}}

then we can define a `DeleteView` like:

{{{
class DeleteView(SingleObjectTemplateResponseMixin, BaseSuccessMessageMixin, BaseDeleteView):
    success_message = _('The object has been deleted successfully')
}}}

This would make a simple message easily translatable: people can just add a custom translation and the other ones are retained.

The `BaseSuccessMessageMixin` is necessary to make sure that if someone inherits the `SuccessMessageMixin`, it will *not* override the `success_message` once again by the empty string."	New feature	closed	Generic views	dev	Normal	wontfix	translations, success-message, views		Unreviewed	0	0	0	0	0	0
