Ticket #16115: new_hook_save_model_and_relations.diff
File new_hook_save_model_and_relations.diff, 2.2 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/options.py
683 683 """ 684 684 formset.save() 685 685 686 def save_model_and_relations(self, request, obj, form, formsets, change): 687 """ 688 Given a model instance, a bound form and a list of inline formsets 689 save everything in to the database. 690 691 At this point save_form() has already been called, so just 692 form.save_m2m() needs to be called. 693 """ 694 self.save_model(request, new_object, form, change=change) 695 form.save_m2m() 696 for formset in formsets: 697 self.save_formset(request, form, formset, change=change) 698 686 699 def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): 687 700 opts = self.model._meta 688 701 app_label = opts.app_label … … 886 899 prefix=prefix, queryset=inline.queryset(request)) 887 900 formsets.append(formset) 888 901 if all_valid(formsets) and form_validated: 889 self.save_model(request, new_object, form, change=False) 890 form.save_m2m() 891 for formset in formsets: 892 self.save_formset(request, form, formset, change=False) 902 self.save_model_and_relations(request, new_object, form, formset, change=False) 893 903 894 904 self.log_addition(request, new_object) 895 905 return self.response_add(request, new_object) … … 988 998 formsets.append(formset) 989 999 990 1000 if all_valid(formsets) and form_validated: 991 self.save_model(request, new_object, form, change=True) 992 form.save_m2m() 993 for formset in formsets: 994 self.save_formset(request, form, formset, change=True) 1001 self.save_model_and_relations(request, new_object, form, formset, change=True) 995 1002 996 1003 change_message = self.construct_change_message(request, form, formsets) 997 1004 self.log_change(request, new_object, change_message)