- Check for model using isinstance

- Check for model using isinstance and pk using _get_pk_value
This commit is contained in:
John R. Tipton 2015-02-19 09:03:39 -05:00
parent 16a55e1924
commit cc2e489f75

View file

@ -65,9 +65,9 @@ class LogEntryManager(models.Manager):
pk_field = instance._meta.pk.name
pk = getattr(instance, pk_field, None)
# Check to make sure that we got an pk not a class object.
if hasattr(pk, '_meta'):
pk = getattr(instance, '%s_id' % pk_field, None)
# Check to make sure that we got an pk not a model object.
if isinstance(pk, models.Model):
pk = self._get_pk_value(pk)
return pk