summaryrefslogtreecommitdiffstats
path: root/webapp/django/core/management/commands/cleanup.py
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/django/core/management/commands/cleanup.py')
-rw-r--r--webapp/django/core/management/commands/cleanup.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/webapp/django/core/management/commands/cleanup.py b/webapp/django/core/management/commands/cleanup.py
new file mode 100644
index 0000000000..a5c932b686
--- /dev/null
+++ b/webapp/django/core/management/commands/cleanup.py
@@ -0,0 +1,11 @@
+import datetime
+from django.core.management.base import NoArgsCommand
+
+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
+ Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
+ transaction.commit_unless_managed()