how to delete int object in django

80 views Asked by At

After filtering and updating I have to delete the objscts, How to solve the isuue,

AttributeError: 'int' object has no attribute 'delete'

 def handle(self, *args, **options):
       trees.objects.filter(old=True).update(new=False).delete()

My objective is to first filte all the old trees as True and new as False then updating I have to delete all the object list.

1

There are 1 answers

4
willeM_ Van Onsem On

You then filter with old=True, new=False, so you do not update:

def handle(self, *args, **options):
    trees.objects.filter(old=True, new=False).delete()