import logging from django.utils import timezone from .models import Participant, TrashedParticipant logger = logging.getLogger(__name__) def purge_participants(): now = timezone.now() for p in Participant.objects.filter(purge_at__lte=now): logger.info('Purge participant \'%s\'', p) p.delete() for p in TrashedParticipant.objects.filter(purge_at__lte=now): logger.info('Purge participant from trash \'%s\'', p) p.delete()