Ticket #12780: ticket12780.patch

File ticket12780.patch, 1.7 KB (added by mrts, 15 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 9dfdb8b..fd6e719 100644
    a b class ModelAdmin(BaseModelAdmin):  
    411411        for inline in self.inline_instances:
    412412            yield inline.get_formset(request, obj)
    413413
     414    def formsets_are_valid(self, formsets, form, form_validated, new_object,
     415            request):
     416        "Hook for doing combined form/formset validation."
     417        return all_valid(formsets)
     418
    414419    def log_addition(self, request, object):
    415420        """
    416421        Log that an object has been successfully added.
    class ModelAdmin(BaseModelAdmin):  
    785790                                  save_as_new=request.POST.has_key("_saveasnew"),
    786791                                  prefix=prefix, queryset=inline.queryset(request))
    787792                formsets.append(formset)
    788             if all_valid(formsets) and form_validated:
     793            if self.formsets_are_valid(formsets, form, form_validated,
     794                    new_object, request) and form_validated:
    789795                self.save_model(request, new_object, form, change=False)
    790796                form.save_m2m()
    791797                for formset in formsets:
    class ModelAdmin(BaseModelAdmin):  
    885891
    886892                formsets.append(formset)
    887893
    888             if all_valid(formsets) and form_validated:
     894            if self.formsets_are_valid(formsets, form, form_validated,
     895                    new_object, request) and form_validated:
    889896                self.save_model(request, new_object, form, change=True)
    890897                form.save_m2m()
    891898                for formset in formsets:
Back to Top