Soft delete for Django ORM, with support for undelete.
Python HTML
Switch branches/tags
Nothing to show
Latest commit eb633fe Jan 3, 2017 @scoursen committed on GitHub Merge pull request #39 from bashu/patch-1


Soft delete for Django ORM, with support for undelete.

This project provides undelete of soft-deleted objects, along with proper undeletion of related objects.

Inspired by


  • Django 1.7
  • django.contrib.contenttypes


There are simple templates files in templates/. You will need to add Django's egg loader to use the templates as is:


Add the project softdelete to your INSTALLED_APPS for through-the-web undelete support.


How It Works

Central to the ability to undelete a soft-deleted model is the concept of changesets. When you soft-delete an object, any objects referencing it via a ForeignKey, ManyToManyField, or OneToOneField will also be soft-deleted. This mimics the traditional CASCADE behavior of a SQL DELETE.

When the soft-delete is performed, the system makes a ChangeSet object which tracks all affected objects of this delete request. Later, when an undelete is requested, this ChangeSet is referenced to do a cascading undelete.

If you are undeleting an object that was part of a ChangeSet, that entire ChangeSet is undeleted.

Once undeleted, the ChangeSet object is removed from the underlying database with a regular ("hard") delete.


Can be tested directly with the following command: test softdelete --settings="softdelete.settings"