diff options
| author | Adam Johnson <me@adamj.eu> | 2025-03-12 11:05:50 +0000 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-03-12 16:25:28 -0300 |
| commit | 27b68bcadf1ab2e9f7fd223aed42db352ccdc62d (patch) | |
| tree | 14e4e19a450da3cd0e92402eb0017fa43db66b4f /django | |
| parent | ed984f2ac4923d6bc625adb4e8d9146765a02ab1 (diff) | |
Fixed #36234 -- Restored single_object argument to LogEntry.objects.log_actions().
Thank you Adam Johnson for the report and fix. Thank you Sarah Boyce for
your spot on analysis.
Regression in c09bceef68e5abb79accedd12dade16aa6577a09, which is
partially reverted in this branch.
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/models.py | 8 | ||||
| -rw-r--r-- | django/contrib/admin/options.py | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 453e65cf01..57122dac35 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -24,7 +24,9 @@ ACTION_FLAG_CHOICES = [ class LogEntryManager(models.Manager): use_in_migrations = True - def log_actions(self, user_id, queryset, action_flag, change_message=""): + def log_actions( + self, user_id, queryset, action_flag, change_message="", *, single_object=False + ): if isinstance(change_message, list): change_message = json.dumps(change_message) @@ -45,7 +47,9 @@ class LogEntryManager(models.Manager): if len(log_entry_list) == 1: instance = log_entry_list[0] instance.save() - return instance + if single_object: + return instance + return [instance] return self.model.objects.bulk_create(log_entry_list) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 090b12151a..3c2cf9d130 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -946,6 +946,7 @@ class ModelAdmin(BaseModelAdmin): queryset=[obj], action_flag=ADDITION, change_message=message, + single_object=True, ) def log_change(self, request, obj, message): @@ -961,6 +962,7 @@ class ModelAdmin(BaseModelAdmin): queryset=[obj], action_flag=CHANGE, change_message=message, + single_object=True, ) def log_deletions(self, request, queryset): |
