equal
deleted
inserted
replaced
5 |
5 |
6 Can be run as a cronjob to clean out old data from the database (only expired |
6 Can be run as a cronjob to clean out old data from the database (only expired |
7 sessions at the moment). |
7 sessions at the moment). |
8 """ |
8 """ |
9 |
9 |
10 import datetime |
10 from django.core import management |
11 from django.db import transaction |
|
12 from django.contrib.sessions.models import Session |
|
13 |
|
14 def clean_up(): |
|
15 """Clean up expired sessions.""" |
|
16 Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() |
|
17 transaction.commit_unless_managed() |
|
18 |
11 |
19 if __name__ == "__main__": |
12 if __name__ == "__main__": |
20 clean_up() |
13 management.call_command('cleanup') |