'how to delete int object in django

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.



Solution 1:[1]

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()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Willem Van Onsem