Ticket #12749: 12206.patch

File 12206.patch, 2.1 KB (added by Chris.Wesseling@…, 5 years ago)

Patch containing faulty bits of changeset 12206. patch using -R or --reverse

  • django/trunk/django/contrib/admin/options.py

     
    580580        messages.info(request, message)
    581581
    582     def save_form(self, request, form, change, commit=False):
     582    def save_form(self, request, form, change):
    583583        """
    584584        Given a ModelForm return an unsaved instance. ``change`` is True if
    585585        the object is being changed, and False if it's being added.
    586586        """
    587         return form.save(commit=commit)
     587        return form.save(commit=False)
    588588
    589589    def save_model(self, request, obj, form, change):
     
    759759            form = ModelForm(request.POST, request.FILES)
    760760            if form.is_valid():
    761                 # Save the object, even if inline formsets haven't been
    762                 # validated yet. We need to pass the valid model to the
    763                 # formsets for validation. If the formsets do not validate, we
    764                 # will delete the object.
    765                 new_object = self.save_form(request, form, change=False, commit=True)
     761                new_object = self.save_form(request, form, change=False)
    766762                form_validated = True
    767763            else:
     
    780776                formsets.append(formset)
    781777            if all_valid(formsets) and form_validated:
     778                self.save_model(request, new_object, form, change=False)
     779                form.save_m2m()
    782780                for formset in formsets:
    783781                    self.save_formset(request, form, formset, change=False)
     
    785783                self.log_addition(request, new_object)
    786784                return self.response_add(request, new_object)
    787             elif form_validated:
    788                 # The form was valid, but formsets were not, so delete the
    789                 # object we saved above.
    790                 new_object.delete()
    791785        else:
    792786            # Prepare the dict of initial data from the request.
Back to Top