From e848b756e3c2067f75b04c7235f8976b39a04097 Mon Sep 17 00:00:00 2001 From: Evan Andrews Date: Tue, 11 Jun 2024 14:48:28 +1000 Subject: [PATCH] Add clarifying comments to _get_pk_value --- auditlog/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auditlog/models.py b/auditlog/models.py index a1f3993..1ae8dbc 100644 --- a/auditlog/models.py +++ b/auditlog/models.py @@ -213,10 +213,12 @@ class LogEntryManager(models.Manager): :type instance: Model :return: The primary key value of the given model instance. """ + # Should be equivalent to `instance.pk`. pk_field = instance._meta.pk.attname pk = getattr(instance, pk_field, None) # Check to make sure that we got a pk not a model object. + # Should be guaranteed as we used `attname` above, not `name`. assert not isinstance(pk, models.Model) return pk