def clear_old_log_entries(): """ Removes older log entries, if the appropriate setting has been set """ if hasattr(settings, 'DJANGO_CRON_DELETE_LOGS_OLDER_THAN'): delta = timedelta(days=settings.DJANGO_CRON_DELETE_LOGS_OLDER_THAN) CronJobLog.objects.filter(end_time__lt=get_current_time() - delta).delete()