Opened 5 years ago

Closed 5 years ago

#14017 closed (fixed)

Wrong comment in django.contrib.admin.options log_deletion

Reported by: akaariai Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Comment of django.contrib.admin.options log_deletion says:

Log that an object has been successfully deleted. Note that since the
object is deleted, it might no longer be safe to call *any* methods
on the object, hence this method getting object_repr.

However this function is called before the object is deleted (from admin.actions delete_selected() and admin.options delete_view().

The changeset that changed the order of obj.delete() and log_deletion() is r10686 fixing the issue reported in #10889. The reason for the change is that log_deletion needs the pk of the object, but this is set to none when obj.delete() is called.

The comment should probably mention that this function is called before deletion, as opposed to log_change and log_addition.

Attachments (1)

14017.diff (716 bytes) - added by fisadev 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by fisadev

comment:1 Changed 5 years ago by fisadev

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by Honza_Kral

  • Resolution set to fixed
  • Status changed from new to closed

(In [14197]) Fixed #14017 -- wrong comment on log_deletion method of ModelAdmin

Also added a transaction around the deletion view to preserve DB state (and rollback the creation of LogEntry object in case the deletion fails)

Note: See TracTickets for help on using tickets.
Back to Top