📅  最后修改于: 2023-12-03 15:18:35.415000             🧑  作者: Mango
SoftDelete is a Python package designed to simplify the process of enabling soft deletion for your Python models. Soft deletion allows you to delete records without actually deleting them from the database - giving you the ability to recover them later if necessary.
You can install SoftDelete using pip:
pip install softdelete
Using SoftDelete is easy - just import the SoftDeleteModel
class and inherit from it in your models:
from softdelete.models import SoftDeleteModel
class MyModel(SoftDeleteModel):
# Your fields and methods here
Once SoftDelete is set up on your model, you can soft-delete records using the delete()
method instead of objects.delete()
. Soft-deleted records are ignored by the objects.all()
and objects.filter()
methods, but can be retrieved using the objects.deleted()
method.
SoftDelete is a convenient package for enabling soft deletion in your Python models. Give it a try and simplify your soft delete process today!