DEV Community

Cover image for Soft Delete Method
Ankit Lodhi
Ankit Lodhi

Posted on

Soft Delete Method

from django.db import models

class SoftDeleteManager(models.Manager):
''' Use this manager to get objects that have a deleted field '''
def get_query_set(self):
return super(SoftDeleteManager, self).get_query_set().filter(deleted=False)
def all_with_deleted(self):
return super(SoftDeleteManager, self).get_query_set()
def deleted_set(self):
return super(SoftDeleteManager, self).get_query_set().filter(deleted=True)

Top comments (0)