Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clearsessions.py 650B

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