From 074cde7cd5cf70b02914a2f567a938b5318e554f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 23 Feb 2020 15:04:30 +0100 Subject: [PATCH] audit: save model's name or string representation --- passbook/audit/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/passbook/audit/models.py b/passbook/audit/models.py index 168daa79d..918bbf657 100644 --- a/passbook/audit/models.py +++ b/passbook/audit/models.py @@ -33,11 +33,15 @@ def sanitize_dict(source: Dict[Any, Any]) -> Dict[Any, Any]: source[key] = sanitize_dict(value) elif isinstance(value, models.Model): model_content_type = ContentType.objects.get_for_model(value) + name = str(value) + if hasattr(value, "name"): + name = value.name source[key] = sanitize_dict( { "app": model_content_type.app_label, - "name": model_content_type.model, + "model_name": model_content_type.model, "pk": value.pk, + "name": name, } ) elif isinstance(value, UUID):