{"id":13625716,"url":"https://github.com/makinacorpus/django-safedelete","last_synced_at":"2025-04-16T10:32:56.938Z","repository":{"id":9032404,"uuid":"10792977","full_name":"makinacorpus/django-safedelete","owner":"makinacorpus","description":"Mask your objects instead of deleting them from your database.","archived":false,"fork":false,"pushed_at":"2023-11-13T09:43:02.000Z","size":368,"stargazers_count":667,"open_issues_count":49,"forks_count":122,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-04-14T09:41:06.173Z","etag":null,"topics":["django","python"],"latest_commit_sha":null,"homepage":"https://django-safedelete.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/makinacorpus.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES","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":"AUTHORS"}},"created_at":"2013-06-19T13:23:35.000Z","updated_at":"2024-04-14T08:00:56.000Z","dependencies_parsed_at":"2024-01-14T07:19:43.500Z","dependency_job_id":null,"html_url":"https://github.com/makinacorpus/django-safedelete","commit_stats":{"total_commits":351,"total_committers":47,"mean_commits":7.468085106382978,"dds":"0.45584045584045585","last_synced_commit":"179288b840205b827570ec3db1d1365116155e6e"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makinacorpus%2Fdjango-safedelete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makinacorpus%2Fdjango-safedelete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makinacorpus%2Fdjango-safedelete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makinacorpus%2Fdjango-safedelete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makinacorpus","download_url":"https://codeload.github.com/makinacorpus/django-safedelete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249228274,"owners_count":21233852,"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":["django","python"],"created_at":"2024-08-01T21:02:00.180Z","updated_at":"2025-04-16T10:32:56.706Z","avatar_url":"https://github.com/makinacorpus.png","language":"Python","funding_links":[],"categories":["Python","Django"],"sub_categories":["Repositories"],"readme":"Django safedelete\n=================\n\n.. image:: https://github.com/makinacorpus/django-safedelete/workflows/Python%20application/badge.svg\n    :target: https://github.com/makinacorpus/django-safedelete/actions?query=workflow%3A%22Python+application%22\n\n.. image:: https://img.shields.io/pypi/dm/django-safedelete.svg\n        :target: https://pypi.python.org/pypi/django-safedelete\n\n.. image:: https://coveralls.io/repos/makinacorpus/django-safedelete/badge.png\n    :target: https://coveralls.io/r/makinacorpus/django-safedelete\n\n\nWhat is it ?\n------------\n\nFor various reasons, you may want to avoid deleting objects from your database.\n\nThis Django application provides an abstract model, that allows you to transparently retrieve or delete your objects,\nwithout having them deleted from your database.\n\nYou can choose what happens when you delete an object :\n - it can be masked from your database (SOFT_DELETE, the default behavior)\n - it can be masked from your database and mask any dependent models. (SOFT_DELETE_CASCADE)\n - it can be normally deleted (HARD_DELETE)\n - it can be hard-deleted, but if its deletion would delete other objects, it will only be masked (HARD_DELETE_NOCASCADE)\n - it can be never deleted or masked from your database (NO_DELETE, use with caution)\n\n\nExample\n-------\n\n.. code-block:: python\n\n    # imports\n    from safedelete.models import SafeDeleteModel\n    from safedelete.models import HARD_DELETE_NOCASCADE\n\n    # Models\n\n    # We create a new model, with the given policy : Objects will be hard-deleted, or soft deleted if other objects would have been deleted too.\n    class Article(SafeDeleteModel):\n        _safedelete_policy = HARD_DELETE_NOCASCADE\n\n        name = models.CharField(max_length=100)\n\n    class Order(SafeDeleteModel):\n        _safedelete_policy = HARD_DELETE_NOCASCADE\n\n        name = models.CharField(max_length=100)\n        articles = models.ManyToManyField(Article)\n\n\n    # Example of use\n\n    \u003e\u003e\u003e article1 = Article(name='article1')\n    \u003e\u003e\u003e article1.save()\n\n    \u003e\u003e\u003e article2 = Article(name='article2')\n    \u003e\u003e\u003e article2.save()\n\n    \u003e\u003e\u003e order = Order(name='order')\n    \u003e\u003e\u003e order.save()\n    \u003e\u003e\u003e order.articles.add(article1)\n\n    # This article will be masked, but not deleted from the database as it is still referenced in an order.\n    \u003e\u003e\u003e article1.delete()\n\n    # This article will be deleted from the database.\n    \u003e\u003e\u003e article2.delete()\n\n\nCompatibilities\n---------------\n\n* Branch 0.2.x is compatible with django \u003e= 1.2\n* Branch 0.3.x is compatible with django \u003e= 1.4\n* Branch 0.4.x is compatible with django \u003e= 1.8\n* Branch 0.5.x is compatible with django \u003e= 1.11\n* Branch 1.0.x, 1.1.x and 1.2.x are compatible with django \u003e= 2.2\n* Branch 1.3.x is compatible with django \u003e= 3.2 and Python \u003e= 3.7\n\nCurrent branch (1.3.x) is tested with :\n\n*  Django 3.2 using python 3.7 to 3.10.\n*  Django 4.0 using python 3.8 to 3.10.\n*  Django 4.1 using python 3.8 to 3.10.\n*  Django 4.2 using python 3.8 to 3.11.\n\n\nInstallation\n------------\n\nInstalling from pypi (using pip). ::\n\n    pip install django-safedelete\n\n\nInstalling from github. ::\n\n    pip install -e git://github.com/makinacorpus/django-safedelete.git#egg=django-safedelete\n\nAdd ``safedelete`` in your ``INSTALLED_APPS``:\n\n.. code-block:: python\n\n    INSTALLED_APPS = [\n        'safedelete',\n        [...]\n    ]\n\n\nThe application doesn't have any special requirement.\n\n\nConfiguration\n-------------\n\nIn the main django settings you can activate the boolean variable ``SAFE_DELETE_INTERPRET_UNDELETED_OBJECTS_AS_CREATED``.\nIf you do this the ``update_or_create()`` function from django's standard manager class will return ``True`` for\nthe ``created`` variable if the object was soft-deleted and is now \"revived\".\n\nBy default, the field that indicates a database entry is soft-deleted is ``deleted``, however, you can override the field name\nusing the ``SAFE_DELETE_FIELD_NAME`` setting.\n\nDocumentation\n-------------\n\nThe documentation is available `here \u003chttp://django-safedelete.readthedocs.org\u003e`_. Generate your own documentation using:\n\n    tox -e docs\n\n\nLicensing\n---------\n\nPlease see the LICENSE file.\n\nContacts\n--------\n\nPlease see the AUTHORS file.\n\n.. image:: https://drupal.org/files/imagecache/grid-3/Logo_slogan_300dpi.png\n    :target: http://www.makina-corpus.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakinacorpus%2Fdjango-safedelete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakinacorpus%2Fdjango-safedelete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakinacorpus%2Fdjango-safedelete/lists"}