Ticket #10889: admin-log-deletion.diff
File admin-log-deletion.diff, 2.3 KB (added by , 14 years ago) |
---|
-
django/contrib/admin/options.py
445 445 change_message = message 446 446 ) 447 447 448 def log_deletion(self, request, object , object_repr):448 def log_deletion(self, request, object_pk, object_repr): 449 449 """ 450 450 Log that an object has been successfully deleted. Note that since the 451 451 object is deleted, it might no longer be safe to call *any* methods 452 on the object, hence this method getting object_repr .452 on the object, hence this method getting object_repr and object_pk. 453 453 454 454 The default implementation creates an admin LogEntry object. 455 455 """ … … 457 457 LogEntry.objects.log_action( 458 458 user_id = request.user.id, 459 459 content_type_id = ContentType.objects.get_for_model(self.model).pk, 460 object_id = object .pk,460 object_id = object_pk, 461 461 object_repr = object_repr, 462 462 action_flag = DELETION 463 463 ) … … 1112 1116 if perms_needed: 1113 1117 raise PermissionDenied 1114 1118 obj_display = force_unicode(obj) 1115 self.log_deletion(request, obj, obj_display)1119 obj_pk = obj.pk 1116 1120 obj.delete() 1121 self.log_deletion(request, obj_pk, obj_display) 1117 1122 1118 1123 self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)}) 1119 1124 -
django/contrib/admin/actions.py
43 43 if n: 44 44 for obj in queryset: 45 45 obj_display = force_unicode(obj) 46 modeladmin.log_deletion(request, obj , obj_display)46 modeladmin.log_deletion(request, obj.pk, obj_display) 47 47 queryset.delete() 48 48 modeladmin.message_user(request, _("Successfully deleted %(count)d %(items)s.") % { 49 49 "count": n, "items": model_ngettext(modeladmin.opts, n)