| author | ymh <ymh.work@gmail.com> |
| Wed, 20 Jan 2010 00:34:04 +0100 | |
| changeset 0 | 0d40e90630ef |
| permissions | -rw-r--r-- |
| 0 | 1 |
import datetime |
2 |
from django.core.management.base import NoArgsCommand |
|
3 |
||
4 |
class Command(NoArgsCommand): |
|
5 |
help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)." |
|
6 |
||
7 |
def handle_noargs(self, **options): |
|
8 |
from django.db import transaction |
|
9 |
from django.contrib.sessions.models import Session |
|
10 |
Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() |
|
11 |
transaction.commit_unless_managed() |