django-auditlog/auditlog_tests
Darren Maki cd0d3ea311
Audit changes to FK fields when saved using *_id naming. (#525)
* Audit changes to FK fields when saved using *_id naming.

In Django you can save changes to a FK field on a model using the ID
field name (attname) in addition to the regular FK field name with:

    model.related_model_id = 42
    model.save(update_fields=["related_model_id'])

or:

    model.related_model = related_model
    model.save(update_fields=["related_model_id'])

as opposed to the more common:

    model.related_model = related_model
    model.save(update_fields=["related_model'])

This change ensures those model changes are logged properly.

* Apply suggested change from code review.

* Add a CHANGELOG entry for the fix.
2023-05-08 18:56:01 +03:30
..
fixtures Added support for Correlation ID 2022-12-23 15:09:32 +01:00
templates Added ACCESS action and enabled logging of object accesses (#436) 2022-11-07 08:51:00 +01:00
__init__.py Remove default_app_config configuration 2022-05-02 14:48:58 +02:00
admin.py Use admin for test site 2020-09-07 16:52:32 +02:00
apps.py Add black and format files with black. 2020-12-06 23:10:18 +01:00
manage.py Clean up project structure 2020-09-07 16:52:32 +02:00
models.py Fix repr of a json field in field changes (#489) 2022-12-30 08:28:55 +01:00
test_commands.py Add flake8 to pre-commit config (#387) 2022-06-18 20:50:25 +04:30
test_settings.py Switch MIDDLEWARE from a tuple to a list 2022-06-28 19:20:02 +02:00
tests.py Audit changes to FK fields when saved using *_id naming. (#525) 2023-05-08 18:56:01 +03:30
urls.py Added ACCESS action and enabled logging of object accesses (#436) 2022-11-07 08:51:00 +01:00
views.py Added ACCESS action and enabled logging of object accesses (#436) 2022-11-07 08:51:00 +01:00