2008-07-06 14:39:44 +08:00
|
|
|
from django.core.management.base import NoArgsCommand
|
2011-11-20 19:04:37 +08:00
|
|
|
from django.utils import timezone
|
2008-07-06 14:39:44 +08:00
|
|
|
|
|
|
|
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
|
2011-11-20 19:04:37 +08:00
|
|
|
Session.objects.filter(expire_date__lt=timezone.now()).delete()
|
2008-07-06 14:39:44 +08:00
|
|
|
transaction.commit_unless_managed()
|