tags:

views:

25

answers:

1

I'm using the django messages framework for user notifications and update_object to handle saving of forms. When a form is successfully posted the default message is [MyModel] successfully saved or similar.

I want to change this message to a custom one ("Your changes were saved"), either for all form posts or for every use of update_object.

Is this possible?

Thanks!

+1  A: 

I am assuming that you are talking about the update_object generic view.

If that is the case then there is no way (hook) to change the success message at present (Django 1.2.3). You can see this for yourself in the source code. Just look for update_object.

One rather flaky way to do this would be to use a custom post_save_redirect and render the message yourself. The post_save_redirect can be a simple view to display the appropriate success message. This will mean losing the redirection to the object's permalink though.

You can also try adding a custom message (using messages.success) and then redirect to the saved object's permalink in the wrapper. I haven't tried this myself so I do not know how this will turn out.

Manoj Govindan