django-auditlog/auditlog_tests/test_app
Lukas Graf d02ed6b9e0
Make diffing more robust for polymorphic models (#784)
* Add failing test for diffing polymorphic model instances.

* Make diffing more robust for polymorphic models:

When working with polymorphic models, where a child model inherits from a
parent model, Django's pre_save signal may send model instances in a way
where the log_update() handler receives an instance of the child as the
`old` model, but an instance of the parent as the `new` model.

This leads to a `FieldDoesNotExist` error when a field that only exists on the
child was modified, and `get_field_value()` attempts look up that field on the
parent.

This change makes diffing polymorphic models more robust by considering this
case in `get_default_value()`. Changes to those child fields won't be tracked
in these cases, but at least `django-auditlog` won't prevent the model from
being saved.
2025-11-25 09:12:41 +01:00
..
fixtures Let CI also check for missing migrations (#706) 2025-03-19 19:58:43 +03:30
templates Let CI also check for missing migrations (#706) 2025-03-19 19:58:43 +03:30
__init__.py Let CI also check for missing migrations (#706) 2025-03-19 19:58:43 +03:30
apps.py Let CI also check for missing migrations (#706) 2025-03-19 19:58:43 +03:30
mask.py Add support for custom masking functions (#725) 2025-06-09 16:59:59 +03:30
models.py Make diffing more robust for polymorphic models (#784) 2025-11-25 09:12:41 +01:00
urls.py Let CI also check for missing migrations (#706) 2025-03-19 19:58:43 +03:30
views.py Let CI also check for missing migrations (#706) 2025-03-19 19:58:43 +03:30