mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Log an entry only if there are changes in model on update
This commit is contained in:
parent
19291f54d9
commit
ee22a84020
1 changed files with 7 additions and 5 deletions
|
|
@ -35,11 +35,13 @@ def log_update(sender, instance, **kwargs):
|
|||
|
||||
changes = model_instance_diff(old, new)
|
||||
|
||||
log_entry = LogEntry.objects.log_create(
|
||||
instance,
|
||||
action=LogEntry.Action.UPDATE,
|
||||
changes=json.dumps(changes),
|
||||
)
|
||||
# Log an entry only if there are changes
|
||||
if changes:
|
||||
log_entry = LogEntry.objects.log_create(
|
||||
instance,
|
||||
action=LogEntry.Action.UPDATE,
|
||||
changes=json.dumps(changes),
|
||||
)
|
||||
|
||||
|
||||
def log_delete(sender, instance, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue