Ticket #6406: admin_options.diff
File admin_options.diff, 2.1 KB (added by , 16 years ago) |
---|
-
contrib/admin/options.py
353 353 for inline in self.inline_instances: 354 354 yield inline.get_formset(request, obj) 355 355 356 def _save_form(self, request, model, form, commit=True) : 357 return form.save(commit=commit) 358 359 def _save_formset(self, request, model, formset) : 360 return formset.save() 361 356 362 def save_add(self, request, model, form, formsets, post_url_continue): 357 363 """ 358 364 Saves the object in the "add" stage and returns an HttpResponseRedirect. … … 362 368 from django.contrib.admin.models import LogEntry, ADDITION 363 369 from django.contrib.contenttypes.models import ContentType 364 370 opts = model._meta 365 new_object = form.save(commit=True)371 new_object = self._save_form(request, model, form, commit=True) 366 372 367 373 if formsets: 368 374 for formset in formsets: 369 375 # HACK: it seems like the parent obejct should be passed into 370 376 # a method of something, not just set as an attribute 371 377 formset.instance = new_object 372 formset.save()378 self._save_formset(request, model, form) 373 379 374 380 pk_value = new_object._get_pk_val() 375 381 LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), ADDITION) … … 412 418 from django.contrib.admin.models import LogEntry, CHANGE 413 419 from django.contrib.contenttypes.models import ContentType 414 420 opts = model._meta 415 new_object = form.save(commit=True)421 new_object = self._save_form(request, model, form, commit=True) 416 422 pk_value = new_object._get_pk_val() 417 423 418 424 if formsets: 419 425 for formset in formsets: 420 formset.save()426 self._save_formset(request, model, form) 421 427 422 428 # Construct the change message. 423 429 change_message = []