django-easy-audit
django-easy-audit copied to clipboard
Objects' default manager should be used rathern than "model.objects"
Easy audit signal handlers assume that all model instances are reachable via Model.objects.get(). This might not be the case when model manager for "objects" is redefined (e.g. for something like SoftDeletableManager in django-model-utils. If that's the case, easy audit signal handling can fail with DoesNotExist when trying to get old value, e.g. here:
if not created:
old_model = sender.objects.get(pk=instance.pk)
I think it could be worker around by using models' _default_manager, as described at https://docs.djangoproject.com/en/3.1/topics/db/managers/#django.db.models.Model._default_manager
Will you have some time in the next couple weeks to implement a PR?
Yup, will try.
Created pull request :)
Any chance this would get merged? The PR is simple enough and should be non-controversial. Thank you!