Ticket #10889: admin-log-deletion.diff

File admin-log-deletion.diff, 2.3 KB (added by 3point2, 14 years ago)
  • django/contrib/admin/options.py

     
    445445            change_message  = message
    446446        )
    447447
    448     def log_deletion(self, request, object, object_repr):
     448    def log_deletion(self, request, object_pk, object_repr):
    449449        """
    450450        Log that an object has been successfully deleted. Note that since the
    451451        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.
    453453
    454454        The default implementation creates an admin LogEntry object.
    455455        """
     
    457457        LogEntry.objects.log_action(
    458458            user_id         = request.user.id,
    459459            content_type_id = ContentType.objects.get_for_model(self.model).pk,
    460             object_id       = object.pk,
     460            object_id       = object_pk,
    461461            object_repr     = object_repr,
    462462            action_flag     = DELETION
    463463        )
     
    11121116            if perms_needed:
    11131117                raise PermissionDenied
    11141118            obj_display = force_unicode(obj)
    1115             self.log_deletion(request, obj, obj_display)
     1119            obj_pk = obj.pk
    11161120            obj.delete()
     1121            self.log_deletion(request, obj_pk, obj_display)
    11171122
    11181123            self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
    11191124
  • django/contrib/admin/actions.py

     
    4343        if n:
    4444            for obj in queryset:
    4545                obj_display = force_unicode(obj)
    46                 modeladmin.log_deletion(request, obj, obj_display)
     46                modeladmin.log_deletion(request, obj.pk, obj_display)
    4747            queryset.delete()
    4848            modeladmin.message_user(request, _("Successfully deleted %(count)d %(items)s.") % {
    4949                "count": n, "items": model_ngettext(modeladmin.opts, n)
Back to Top