﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
162	admin log accesses __repr__ too late  (w/patch)	mfenniak@…	Adrian Holovaty	"If a meta.Model class has a repr function like this:

{{{
    def __repr__(self):
        return ""Object #%s"" % (self.id,)
}}}

When the object is deleted through the administration interface, the user interface shows that: {{{The object ""Object #None"" was deleted successfully.}}}  A similar message appears in the admin log.  It would suggest that the object's representation should be cached before it is deleted for display in the UI and logs.

This quick and simple patch fixes the problem:

{{{
Index: django/views/admin/main.py
===================================================================
--- django/views/admin/main.py  (revision 293)
+++ django/views/admin/main.py  (working copy)
@@ -1056,8 +1059,8 @@
     if request.POST: # The user has already confirmed the deletion.
         if perms_needed:
             raise PermissionDenied
+        obj_repr = repr(obj)
         obj.delete()
-        obj_repr = repr(obj)
         log.log_action(request.user.id, opts.get_content_type_id(), object_id, obj_repr, log.DELETION)
         request.user.add_message('The %s ""%s"" was deleted successfully.' % (opts.verbose_name, obj_repr))
         return HttpResponseRedirect(""../../"")
}}}"	defect	closed	contrib.admin		minor	fixed			Unreviewed	0	0	0	0	0	0
