django-auditlog: Custom signal post_log is triggered even when LogEntry is not created
From https://github.com/jazzband/django-auditlog/blob/master/auditlog/receivers.py#L99
try:
changes = model_instance_diff(
diff_old, diff_new, fields_to_check=fields_to_check
)
if force_log or changes:
LogEntry.objects.log_create(
instance,
action=action,
changes=changes,
force_log=force_log,
)
except BaseException as e:
error = e
finally:
post_log.send(
sender,
instance=instance,
action=action,
error=error,
pre_log_results=pre_log_results,
)
if error:
raise error
When changes
is None implying that the model was saved with no changes, LogEntry object is not created, but the post_log signal is still being send in the finally
block which shouldnt happen.
To reproduce the issue:
- Set any registered model with a receiver for the post_log signal to print a log
- Save an object without any changes
I am using the last master commit for this.
Another issue here is that the “Custom Signals” feature is not released yet but is part of the public documentation already - https://django-auditlog.readthedocs.io/en/latest/internals.html#custom-signals
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (15 by maintainers)
Hey @aabanaag, no, It will be available in V3. we are preparing a beta release for V3 and it will be available soon
It is not decided yet.
That would be great!
@aqeelat created an issue already https://github.com/jazzband/django-auditlog/issues/538