Ticket #4507: newforms-admin-form-save-hooks.diff
File newforms-admin-form-save-hooks.diff, 1.9 KB (added by , 17 years ago) |
---|
-
django/contrib/admin/options.py
292 292 """ 293 293 return self.queryset(request) 294 294 295 def form_save(self, request, form): 296 """ 297 Returns object saved from curent form. 298 """ 299 return form.save(commit=True) 300 301 def form_save_add(self, request, form): 302 """ 303 Returns object saved from current form in add stage. 304 """ 305 return self.form_save(form, request) 306 307 def form_save_change(self, request, form): 308 """ 309 Returns object saved from current form in change stage. 310 """ 311 return self.form_save(form, request) 312 295 313 def save_add(self, request, model, form, post_url_continue): 296 314 """ 297 315 Saves the object in the "add" stage and returns an HttpResponseRedirect. … … 301 319 from django.contrib.admin.models import LogEntry, ADDITION 302 320 from django.contrib.contenttypes.models import ContentType 303 321 opts = model._meta 304 new_object = form.save(commit=True)322 new_object = self.form_save_add(request, form) 305 323 pk_value = new_object._get_pk_val() 306 324 LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, str(new_object), ADDITION) 307 325 msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_object} … … 340 358 from django.contrib.admin.models import LogEntry, CHANGE 341 359 from django.contrib.contenttypes.models import ContentType 342 360 opts = model._meta 343 new_object = form.save(commit=True)361 new_object = self.form_save_change(request, form) 344 362 pk_value = new_object._get_pk_val() 345 363 346 364 # Construct the change message. TODO: Temporarily commented-out,