修复BUG:

[对象.delete]会导致软删除不生效的bug
pull/71/head
猿小天 2022-08-28 14:35:36 +08:00
parent 072282cf39
commit 11a0b6b931
1 changed files with 10 additions and 0 deletions

View File

@ -76,6 +76,16 @@ class CoreModel(models.Model):
verbose_name = '核心模型'
verbose_name_plural = verbose_name
def delete(self, using=None, soft_delete=True, *args, **kwargs):
"""
Soft delete object (set its ``is_deleted`` field to True).
Actually delete object if setting ``soft`` to False.
"""
if soft_delete:
self.is_deleted = True
self.save(using=using)
else:
return super(CoreModel, self).delete(using=using, *args, **kwargs)