A Django app that keeps a log of changes made to an object.
Find a file
August Raack c649629225
Change diff to evaluate PKs for FK relationships (#420)
* Change diff to evaluate PKs for FK relationships

The diff method now evaluates the primary keys for changes to determine
if a new LogEntry should be created. Previously, the diff method was
evaluating the string representation of the object. This was flawed
because cases can occur when a parent object has in memory changes to
its string string representation and the child related object is saved
prior to these in memory changes being persisted. In these cases a new
LogEntry object would be created erroneously. This cases is asserted
with a test and a regression test will verify the bug.

The consequence of these updates is that the ``LogEntry.changes`` field
now stores primary keys rather than string representations for related
objects. To keep the changes dictionary display unaffected by this
update, a method was added to the ``LogEntry`` model. This method looks
up the object display string from the stored foreign key. Exceptions
were written to handle backwards compatibility.

* Added test case to cover another bug

Because the string representation is not unique for every object, relying
on it to determine FK diffs may not capture all changes. This test case
shows another type of scenario that is fixed by comparing primary keys
rather than object string representations. This is likely occurring
fairly regularly but is hard to spot because it is an error of omission.

* Update to docstring and added changelog
2022-12-28 09:51:44 +01:00
.github/workflows Confirm Python 3.11 support (#447) 2022-11-07 09:36:17 +01:00
auditlog Change diff to evaluate PKs for FK relationships (#420) 2022-12-28 09:51:44 +01:00
auditlog_tests Change diff to evaluate PKs for FK relationships (#420) 2022-12-28 09:51:44 +01:00
docs Adding Custom Pre- and Post- Log Hooks (#483) 2022-12-27 20:14:51 +01:00
.gitignore Clean up project structure 2020-09-07 16:52:32 +02:00
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate (#482) 2022-12-19 14:52:51 -05:00
CHANGELOG.md Change diff to evaluate PKs for FK relationships (#420) 2022-12-28 09:51:44 +01:00
CODE_OF_CONDUCT.md Jazzband: Created local 'CODE_OF_CONDUCT.md' from remote 'CODE_OF_CONDUCT.md' 2022-01-04 11:27:52 +01:00
CONTRIBUTING.md Changes for Jazzband (#269) 2020-10-23 12:16:27 +02:00
LICENSE Bump copyright year 2020-09-07 16:52:32 +02:00
pyproject.toml Remove a redundant comment 2022-06-28 19:20:02 +02:00
README.md update readme link (#460) 2022-11-28 09:05:00 +01:00
runtests.py Add black and format files with black. 2020-12-06 23:10:18 +01:00
setup.py Confirm Python 3.11 support (#447) 2022-11-07 09:36:17 +01:00
tox.ini Confirm Python 3.11 support (#447) 2022-11-07 09:36:17 +01:00

django-auditlog

Jazzband Build Status Docs codecov Supported Python versions Supported Django versions

django-auditlog (Auditlog) is a reusable app for Django that makes logging object changes a breeze. Auditlog tries to use as much as Python and Django's built in functionality to keep the list of dependencies as short as possible. Also, Auditlog aims to be fast and simple to use.

Auditlog is created out of the need for a simple Django app that logs changes to models along with the user who made the changes (later referred to as actor). Existing solutions seemed to offer a type of version control, which was found excessive and expensive in terms of database storage and performance.

The core idea of Auditlog is similar to the log from Django's admin. Unlike the log from Django's admin (django.contrib.admin) Auditlog is much more flexible. Also, Auditlog saves a summary of the changes in JSON format, so changes can be tracked easily.

Documentation

The documentation for django-auditlog can be found on https://django-auditlog.readthedocs.org. The source files are available in the docs folder.

License

Auditlog is licensed under the MIT license (see the LICENSE file for details).

Contribute

If you have great ideas for Auditlog, or if you like to improve something, feel free to fork this repository and/or create a pull request. I'm open for suggestions. If you like to discuss something with me (about Auditlog), please open an issue.

Releases

  1. Make sure all tests on master are green
  2. Create a new branch vX.Y.Z from master for that specific release
  3. Update the CHANGELOG release date
  4. Pull request vX.Y.Z -> master
  5. As a project lead, once the PR is merged, create and push a tag vX.Y.Z: this will trigger the release build and a notification will be sent from Jazzband of the availability of two packages (tgz and wheel)
  6. Test the install
  7. Publish the release to PyPI