mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
- Compatibility with django-polymorphic
django-polymorphic self._get_pk_value returns the class object. If this happens, we try adding _id to the pk_field.
This commit is contained in:
parent
4fd8387df0
commit
dc9d6739fe
1 changed files with 6 additions and 1 deletions
|
|
@ -63,7 +63,12 @@ class LogEntryManager(models.Manager):
|
|||
Get the primary key field value for a model instance.
|
||||
"""
|
||||
pk_field = instance._meta.pk.name
|
||||
return getattr(instance, pk_field, None)
|
||||
pk = getattr(instance, pk_field, None)
|
||||
|
||||
# Check to make sure that we got an pk not a class object.
|
||||
if hasattr(pk, '__class__'):
|
||||
pk = getattr(instance, '%s_id' % pk_field, None)
|
||||
return pk
|
||||
|
||||
|
||||
class LogEntry(models.Model):
|
||||
|
|
|
|||
Loading…
Reference in a new issue