[Fixed]-Soft deleting objects in django

4👍

django-softdelete is a library implementing soft delete for Django, with cascading. It also stores the changesets, and allows reverting the deletions (e.g. reverting the whole cascade).

I’m not sure what is it’s maintenance status and quality, but it can at least serve as inspiration, if not a solution by itself.

👤Frax

5👍

Maybe you can use django-paranoid.

It is similar to acts_as_paranoid for rails and is easy to use.

You only need to extend your model with ParanoidModel.

To retrieve the deleted object, you use the objects_with_deleted manager:

MyModel.objects_with_deleted.last()

and if you want to perform a hard delete on an object, use the True parameter:

m = MyModel.objects.last()
m.delete(True)

Leave a comment