from cus_leads.models import CustomerLeads
from datetime import datetime, timedelta


class Command(BaseCommand):
    help = 'Delete objects older than 10 days'

def handle(self, *args, **options):
    CustomerLeads.objects.filter(posting_date__gte=datetime.now() -
        timedelta(days=10)).delete()
self.stdout.write('Deleted objects older than 10 days')
Автоматическое удаление данных старше 10 дней в django