Ticket #21937: 0001-Add-forms_valid-for-the-mixin-to-work-with-django-ex.patch

File 0001-Add-forms_valid-for-the-mixin-to-work-with-django-ex.patch, 1.1 KB (added by david.fischer.ch@…, 7 years ago)

The patch for this contribution

  • django/contrib/messages/views.py

    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): 
    1414            messages.success(self.request, success_message)
    1515        return response
    1616
     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
    1724    def get_success_message(self, cleaned_data):
    1825        if hasattr(self, 'object'):
    1926            cleaned_data['object'] = self.object
Back to Top