1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #34462 -- Made admin log actions in bulk.

This also deprecates ModelAdmin.log_deletion() and
LogEntryManager.log_action().
This commit is contained in:
Akash Kumar Sen
2023-06-12 08:50:55 +05:30
committed by Mariusz Felisiak
parent 45e0c5892f
commit 40b3975e7d
12 changed files with 374 additions and 70 deletions

View File

@@ -1,4 +1,5 @@
from django.contrib import admin
from django.contrib.admin.models import LogEntry, LogEntryManager
from django.db import models
from django.utils.translation import gettext_lazy as _
@@ -86,3 +87,26 @@ class VehicleMixin(Vehicle):
class Car(VehicleMixin):
pass
class InheritedLogEntryManager(LogEntryManager):
model = LogEntry
def log_action(
self,
user_id,
content_type_id,
object_id,
object_repr,
action_flag,
change_message="",
):
return LogEntry.objects.create(
user_id=user_id,
content_type_id=content_type_id,
object_id=str(object_id),
# Changing actual repr to test repr
object_repr="Test Repr",
action_flag=action_flag,
change_message=change_message,
)