app/django/core/management/commands/cleanup.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Tue, 14 Oct 2008 21:33:57 +0000
changeset 328 275a47dd0ac8
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
Add missing blank lines, clean up the doc string and remove white spaces at the end of the lines in reflistprop. Patch by: Pawel Solyga Review by: to-be-reviewed

import datetime
from django.core.management.base import NoArgsCommand

class Command(NoArgsCommand):
    help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)."

    def handle_noargs(self, **options):
        from django.db import transaction
        from django.contrib.sessions.models import Session
        Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
        transaction.commit_unless_managed()