expirelinks.py 339 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
from django.core.management.base import BaseCommand
from django.utils import timezone
from go.models import URL


class Command(BaseCommand):
    help = 'Removes expired links from the database'

    def handle(self, *args, **options):
        for toexpire in URL.objects.filter(expires__lte=timezone.now()):
            toexpire.delete()