#36217: post_save signal is not called when LogEntry has Deletion action
-------------------------------------+-------------------------------------
Reporter: smiling-watermelon | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: LogEntry Signals | Triage Stage: Accepted
post_save |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):
* cc: Akash Kumar Sen, David Wobrock, Nick Pope, Mariusz Felisiak (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thank you for the ticket!
I think this is a consequence of 40b3975e7d3e1464a733c69171ad7d38f8814280
(#34462), as we now use `bulk_create` which doesn't send a `post_save`
signal ([
https://docs.djangoproject.com/en/5.1/ref/models/querysets/#bulk-
create see bulk_create docs]).
The `single_object` kwarg, which decides to use `.save()` (and send
signals), is used for `log_addition` etc but never for `log_deletions`
(even if this is only one object). I believe this is an inconsistency of
behavior we might want to clean up.
I also think that we perhaps should/could document that these signals are
no longer sent as part of the backwards incompatible changes of Django 5.1
(with maybe an alternative suggestion).
Note that it wasn't clear to me why we can't remove `single_object` kwarg
entirely (I'm likely missing something):
{{{#!diff
--- a/django/contrib/admin/models.py
+++ b/django/contrib/admin/models.py
@@ -24,9 +24,7 @@ ACTION_FLAG_CHOICES = [
class LogEntryManager(models.Manager):
use_in_migrations = True
- def log_actions(
- self, user_id, queryset, action_flag, change_message="", *,
single_object=False
- ):
+ def log_actions(self, user_id, queryset, action_flag,
change_message=""):
if isinstance(change_message, list):
change_message = json.dumps(change_message)
@@ -44,7 +42,7 @@ class LogEntryManager(models.Manager):
for obj in queryset
]
- if single_object and log_entry_list:
+ if len(log_entry_list) == 1:
instance = log_entry_list[0]
instance.save()
return instance
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/36217#comment:1>