mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Fix LogEntry.changes_dict() to return {} when json.loads() returns None (#472)
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
This commit is contained in:
parent
cd1ba3d01b
commit
27f57a53ff
3 changed files with 6 additions and 1 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
## Next Release
|
||||
|
||||
#### Fixes
|
||||
|
||||
- fix: Make sure `LogEntry.changes_dict()` returns an empty dict instead of `None` when `json.loads()` returns `None`. ([#472](https://github.com/jazzband/django-auditlog/pull/472))
|
||||
|
||||
## 2.2.1 (2022-11-28)
|
||||
|
||||
#### Fixes
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ class LogEntry(models.Model):
|
|||
:return: The changes recorded in this log entry as a dictionary object.
|
||||
"""
|
||||
try:
|
||||
return json.loads(self.changes)
|
||||
return json.loads(self.changes) or {}
|
||||
except ValueError:
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1841,6 +1841,7 @@ class TestAccessLog(TestCase):
|
|||
log_entry.action, LogEntry.Action.ACCESS, msg="Action is 'ACCESS'"
|
||||
)
|
||||
self.assertEqual(log_entry.changes, "null")
|
||||
self.assertEqual(log_entry.changes_dict, {})
|
||||
|
||||
|
||||
@override_settings(AUDITLOG_DISABLE_ON_RAW_SAVE=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue