django-auditlog/auditlog
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
..
locale Add I18N Support (#762) 2025-09-30 16:15:45 +02:00
management Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
migrations add actor email (#641) 2025-01-30 18:33:51 +03:30
templates/auditlog Add I18N Support (#762) 2025-09-30 16:15:45 +02:00
templatetags Add audit log history view to Django Admin (#743) 2025-08-05 13:02:43 +02:00
__init__.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
admin.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
apps.py feat: give users the option to run the json migration asyncly (#495) 2023-08-13 11:38:21 +02:00
cid.py Drop 'Python 3.9' support (#773) 2025-10-17 17:51:53 +02:00
conf.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
context.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
diff.py Make diffing more robust for polymorphic models (#784) 2025-11-25 09:12:41 +01:00
filters.py Added support for Correlation ID 2022-12-23 15:09:32 +01:00
middleware.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
mixins.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
models.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
receivers.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
registry.py Add CustomLogEntry model support and update tests: (#764) 2025-11-19 09:46:43 +01:00
render.py Add I18N Support (#762) 2025-09-30 16:15:45 +02:00
signals.py feat: include LogEntry instance in post_log signal (#605) 2024-02-08 21:55:46 +01:00