From c75f94d08c1161f4ce8238f1723064f3fdc6872d Mon Sep 17 00:00:00 2001
From: David Fischer <david.fischer.ch@gmail.com>
Date: Mon, 3 Feb 2014 12:12:28 +0100
Subject: [PATCH] Add forms_valid for the mixin to work with
django-extra-views's UpdateWithInlinesView
---
django/contrib/messages/views.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/django/contrib/messages/views.py b/django/contrib/messages/views.py
index 1de732c..d6b9e31 100644
a
|
b
|
class SuccessMessageMixin(object):
|
14 | 14 | messages.success(self.request, success_message) |
15 | 15 | return response |
16 | 16 | |
| 17 | def forms_valid(self, form, inlines): |
| 18 | response = super(SuccessMessageMixin, self).forms_valid(form, inlines) |
| 19 | success_message = self.get_success_message(form.cleaned_data) |
| 20 | if success_message: |
| 21 | messages.success(self.request, success_message) |
| 22 | return response |
| 23 | |
17 | 24 | def get_success_message(self, cleaned_data): |
18 | 25 | if hasattr(self, 'object'): |
19 | 26 | cleaned_data['object'] = self.object |