1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00
Files
django/django/contrib/sessions/management/commands/clearsessions.py
2014-06-19 08:54:59 -04:00

17 lines
623 B
Python

from importlib import import_module
from django.conf import settings
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)."
def handle(self, **options):
engine = import_module(settings.SESSION_ENGINE)
try:
engine.SessionStore.clear_expired()
except NotImplementedError:
self.stderr.write("Session engine '%s' doesn't support clearing "
"expired sessions.\n" % settings.SESSION_ENGINE)