@@ -302,17 +302,7 @@ def _mask_serialized_fields(
302
302
return data
303
303
304
304
305
- class LogEntry (models .Model ):
306
- """
307
- Represents an entry in the audit log. The content type is saved along with the textual and numeric
308
- (if available) primary key, as well as the textual representation of the object when it was saved.
309
- It holds the action performed and the fields that were changed in the transaction.
310
-
311
- If AuditlogMiddleware is used, the actor will be set automatically. Keep in mind that
312
- editing / re-saving LogEntry instances may set the actor to a wrong value - editing LogEntry
313
- instances is not recommended (and it should not be necessary).
314
- """
315
-
305
+ class AbstractLogEntry (models .Model ):
316
306
class Action :
317
307
"""
318
308
The actions that Auditlog distinguishes: creating, updating and deleting objects. Viewing objects
@@ -385,6 +375,7 @@ class Action:
385
375
objects = LogEntryManager ()
386
376
387
377
class Meta :
378
+ abstract = True
388
379
get_latest_by = "timestamp"
389
380
ordering = ["-timestamp" ]
390
381
verbose_name = _ ("log entry" )
@@ -544,6 +535,21 @@ def _get_changes_display_for_fk_field(
544
535
return f"Deleted '{ field .related_model .__name__ } ' ({ value } )"
545
536
546
537
538
+ class LogEntry (AbstractLogEntry ):
539
+ """
540
+ Represents an entry in the audit log. The content type is saved along with the textual and numeric
541
+ (if available) primary key, as well as the textual representation of the object when it was saved.
542
+ It holds the action performed and the fields that were changed in the transaction.
543
+
544
+ If AuditlogMiddleware is used, the actor will be set automatically. Keep in mind that
545
+ editing / re-saving LogEntry instances may set the actor to a wrong value - editing LogEntry
546
+ instances is not recommended (and it should not be necessary).
547
+ """
548
+
549
+ class Meta (AbstractLogEntry .Meta ):
550
+ swappable = "AUDITLOG_LOGENTRY_MODEL"
551
+
552
+
547
553
class AuditlogHistoryField (GenericRelation ):
548
554
"""
549
555
A subclass of py:class:`django.contrib.contenttypes.fields.GenericRelation` that sets some default
0 commit comments