Skip to content

Objects' default manager should be used rathern than "model.objects"Β #175

@JirkaV

Description

@JirkaV

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions