{"id":13796813,"url":"https://github.com/scoursen/django-softdelete","last_synced_at":"2025-05-13T00:31:08.097Z","repository":{"id":38904404,"uuid":"2135311","full_name":"scoursen/django-softdelete","owner":"scoursen","description":"Soft delete for Django ORM, with support for undelete.","archived":false,"fork":false,"pushed_at":"2025-04-10T12:54:03.000Z","size":115,"stargazers_count":383,"open_issues_count":28,"forks_count":101,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-10T14:04:48.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scoursen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-08-01T05:51:33.000Z","updated_at":"2025-04-10T12:54:07.000Z","dependencies_parsed_at":"2025-04-10T13:43:27.899Z","dependency_job_id":"3b972363-5b89-4182-9728-185b394ca949","html_url":"https://github.com/scoursen/django-softdelete","commit_stats":{"total_commits":105,"total_committers":32,"mean_commits":3.28125,"dds":0.4285714285714286,"last_synced_commit":"a4ce020024507e46c702edf002e3c1bacf8e4b59"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoursen%2Fdjango-softdelete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoursen%2Fdjango-softdelete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoursen%2Fdjango-softdelete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoursen%2Fdjango-softdelete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scoursen","download_url":"https://codeload.github.com/scoursen/django-softdelete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253660848,"owners_count":21943824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T23:01:15.616Z","updated_at":"2025-05-13T00:31:07.706Z","avatar_url":"https://github.com/scoursen.png","language":"Python","funding_links":[],"categories":["Soft Delete in ORM Frameworks"],"sub_categories":[],"readme":"# django-softdelete  [![Build Status](https://travis-ci.com/mark0978/django-softdelete.svg?branch=master)](https://travis-ci.com/mark0978/django-softdelete)\n\nSoft delete for Django ORM, with support for undelete.  Supports Django 2.0+\n\nThis project provides undelete of soft-deleted objects, along with proper undeletion of related objects.\n\nInspired by http://codespatter.com/2009/07/01/django-model-manager-soft-delete-how-to-customize-admin/\n\n## Requirements\n\n\n* Django 1.8+\n* django.contrib.contenttypes\n\n## Installation\n\n    pip install django-softdelete\n\n## Configuration\n\nThere are simple templates files in `templates/`.  You will need to add Django's\negg loader to use the templates as is, that would look something like this:\n\n    TEMPLATES = [\n        {\n            'BACKEND': 'django.template.backends.django.DjangoTemplates',\n            'DIRS': '/path/to/my/templates',\n            'OPTIONS': {\n                 'loaders': (\n                      'django.template.loaders.filesystem.Loader',\n                      'django.template.loaders.app_directories.Loader',\n                  ),\n             }\n        },\n    ]\n\nAdd the project `softdelete` to your `INSTALLED_APPS` for\nthrough-the-web undelete support.\n\n    INSTALLED_APPS = (\n    ...\n        'django.contrib.contenttypes',\n        'softdelete',\n    )\n\nUsage\n=====\n- Run `django-admin migrate`\n- For the models that you want __soft delete__ to be implemented in, inherit from the `SoftDeleteObject` with `from softdelete.models import SoftDeleteObject`. Something like `MyCustomModel(SoftDeleteObject, models.Model)`. This will add an extra `deleted_at` field which will appear in the admin form after deleting/undeleting the object\n- If you have a custom manager also make sure to inherit from the `SoftDeleteManager`.\n- After that you can test it by __deleting__ and __undeleting__ objects from your models. Have fun undeleting :)\n\nSettings\n========\n\n|Name|Default| Description                                                                                                                                                                 |\n|---|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n|`SOFTDELETE_CASCADE_ALLOW_DELETE_ALL`|True| Setting to confirm if the logic for deleting related entities should fall back to deleting all model entities in the event of an exception being raised when calling delete |\n\nHow It Works\n============\n\nCentral to the ability to undelete a soft-deleted model is the concept of changesets.  When you\nsoft-delete an object, any objects referencing it via a ForeignKey, ManyToManyField, or OneToOneField will\nalso be soft-deleted.  This mimics the traditional CASCADE behavior of a SQL DELETE.\n\nWhen the soft-delete is performed, the system makes a ChangeSet object which tracks all affected objects of\nthis delete request.  Later, when an undelete is requested, this ChangeSet is referenced to do a cascading\nundelete.\n\nIf you are undeleting an object that was part of a ChangeSet, that entire ChangeSet is undeleted.\n\nOnce undeleted, the ChangeSet object is removed from the underlying database with a regular (\"hard\") delete.\n\nWarnings\n=====\n\nWhen using cascade delete, the default behaviour when the call to delete a related object raises an exception is \nto fallback to deleting all the entities for that model class from the database. You can prevent this behaviour\nby using the `SOFTDELETE_CASCADE_ALLOW_DELETE_ALL` setting. Set this to `False` to prevent the behaviour.\n\n## Testing\n\n\nCan be tested directly with the following command:\n\n    django-admin.py test softdelete --settings=\"softdelete.settings\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscoursen%2Fdjango-softdelete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscoursen%2Fdjango-softdelete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscoursen%2Fdjango-softdelete/lists"}