mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-23 22:35:57 +00:00
Add clarifying comments to _get_pk_value
This commit is contained in:
parent
3baee52127
commit
e848b756e3
1 changed files with 2 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue