diff --git a/django/contrib/sessions/management/__init__.py b/django/contrib/sessions/management/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/sessions/management/commands/__init__.py b/django/contrib/sessions/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/sessions/management/commands/cleansessions.py b/django/contrib/sessions/management/commands/cleansessions.py
new file mode 100644
index 0000000..f5783ba
-
|
+
|
|
| 1 | from django.core.management.base import NoArgsCommand |
| 2 | from django.utils import timezone |
| 3 | |
| 4 | |
| 5 | class Command(NoArgsCommand): |
| 6 | help = "Clean expired sessions." |
| 7 | |
| 8 | def handle_noargs(self, **options): |
| 9 | from django.db import transaction |
| 10 | from django.contrib.sessions.models import Session |
| 11 | Session.objects.filter(expire_date__lt=timezone.now()).delete() |
| 12 | transaction.commit_unless_managed() |
diff --git a/django/core/management/commands/cleanup.py b/django/core/management/commands/cleanup.py
index e19d164..45f3bec 100644
a
|
b
|
|
| 1 | from django.core import management |
1 | 2 | from django.core.management.base import NoArgsCommand |
2 | | from django.utils import timezone |
| 3 | |
3 | 4 | |
4 | 5 | class Command(NoArgsCommand): |
5 | 6 | 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 | |
7 | 8 | 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=timezone.now()).delete() |
11 | | transaction.commit_unless_managed() |
| 9 | management.call_command('cleansessions', **options) |
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 7fa7539..ec8b74e 100644
a
|
b
|
|
1 | 1 | ============================= |
| 2 | |
| 3 | |
| 4 | .. |
2 | 5 | django-admin.py and manage.py |
3 | 6 | ============================= |
4 | 7 | |
… |
… |
cleanup
|
93 | 96 | |
94 | 97 | .. django-admin:: cleanup |
95 | 98 | |
96 | | Can be run as a cronjob or directly to clean out old data from the database |
97 | | (only expired sessions at the moment). |
| 99 | Can be run as a cronjob or directly to clean out old data from the database. |
| 100 | Right now it only calls :djadmin:`cleansessions` management command from |
| 101 | ``django.contrib.sessions``. |
| 102 | |
| 103 | .. versionchanged:: 1.5 |
98 | 104 | |
99 | 105 | compilemessages |
100 | 106 | --------------- |
… |
… |
This command is only available if the :doc:`Sitemaps framework
|
1199 | 1205 | Please refer to its :djadmin:`description <ping_google>` in the Sitemaps |
1200 | 1206 | documentation. |
1201 | 1207 | |
| 1208 | ``django.contrib.sessions`` |
| 1209 | --------------------------- |
| 1210 | |
| 1211 | cleansessions |
| 1212 | ~~~~~~~~~~~~~ |
| 1213 | |
| 1214 | This command is only available if the :doc:`Sessions </topics/http/sessions>` |
| 1215 | (``django.contrib.sessions``) are installed. |
| 1216 | |
| 1217 | Please refer to its :djadmin:`description <cleansessions>` in the Sessions |
| 1218 | documentation. |
| 1219 | |
| 1220 | .. versionadded:: 1.5 |
| 1221 | |
1202 | 1222 | ``django.contrib.staticfiles`` |
1203 | 1223 | ------------------------------ |
1204 | 1224 | |
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
index 11b3488..f5d5862 100644
a
|
b
|
a User account, this will be an appropriate design pattern to follow. However,
|
486 | 486 | the :setting:`AUTH_PROFILE_MODULE` setting, and the |
487 | 487 | :meth:`~django.contrib.auth.models.User.get_profile()` method for accessing |
488 | 488 | the user profile model, should not be used any longer. |
| 489 | |
| 490 | Cleaned :djadmin:`cleanup` management command |
| 491 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 492 | |
| 493 | This command have contained only expired sessions clean up for years. |
| 494 | Therefore new command :djadmin:`cleansessions` in ``django.contrib.sessions`` |
| 495 | do the job and :djadmin:`cleanup` command just call it. |
diff --git a/docs/topics/http/sessions.txt b/docs/topics/http/sessions.txt
index 1f55293..ad9bbd6 100644
a
|
b
|
that is, if any of its dictionary values have been assigned or deleted.
|
573 | 573 | |
574 | 574 | .. _Django settings: ../settings/ |
575 | 575 | |
| 576 | Management commands |
| 577 | =================== |
| 578 | |
| 579 | .. highlight:: console |
| 580 | |
| 581 | ``django.contrib.sessions`` exposes one management commands. |
| 582 | |
| 583 | cleansessions |
| 584 | ------------- |
| 585 | |
| 586 | .. django-admin:: cleansessions |
| 587 | |
| 588 | Cleans expired sessions from database. |
| 589 | |
| 590 | .. versionadded:: 1.5 |
| 591 | |
576 | 592 | Technical details |
577 | 593 | ================= |
578 | 594 | |