How can I easily mark records as deleted in Django models instead of actually deleting them?

前端 未结 5 918
长发绾君心
长发绾君心 2021-02-02 17:20

Instead of deleting records in my Django application, I want to just mark them as \"deleted\" and have them hidden from my active queries. My main reason to do this is to give

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-02 17:56

    There are several packages which provide this functionality: https://www.djangopackages.com/grids/g/deletion/

    I'm developing one https://github.com/meteozond/django-permanent/ It replaces default Manager and QuerySet delete methods to bring in logical deletion. It completely shadows default Django delete methods with one exception - marks models which are inherited from PermanentModel instead of deletion, even if their deletion caused by relation.

提交回复
热议问题