Ticket #8713: core-management-commands-cleanup.diff
File core-management-commands-cleanup.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/core/management/commands/cleanup.py
1 import datetime2 from django.core.management.base import NoArgsCommand3 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 transaction9 from django.contrib.sessions.models import Session10 Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()11 transaction.commit_unless_managed() -
django/contrib/sessions/management/commands/cleanup.py
1 import datetime 2 from django.core.management.base import NoArgsCommand 3 4 class Command(NoArgsCommand): 5 help = "Cleans out expired sessions (can be run as a cronjob)." 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()