﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2796	daily_cleanup outdated and hard to access	sdistefano	Adrian Holovaty	"So I made a patch (first time I'm touching the code, so probably not good enough). It adds a cleanup option to manage.py, which seems more logical to me

here it goes

Index: management.py
===================================================================
--- management.py       (rÃ©vision 3797)
+++ management.py       (copie de travail)
@@ -1187,6 +1187,20 @@
 test.help_doc = 'Runs the test suite for the specified applications, or the entire site if no apps are specified'
 test.args = '[--verbosity] ' + APP_ARGS

+def cleanup():
+       ""Runs the daily cleanup job for this site""
+       from django.conf import settings
+       from django.db import backend, connection, transaction
+       # Clean up old database records
+       cursor = connection.cursor()
+       cursor.execute(""DELETE FROM %s WHERE %s < NOW()"" % \
+               (backend.quote_name('django_session'), backend.quote_name('expire_date')))
+       transaction.commit_unless_managed()
+
+cleanup.help_doc = 'Runs the daily cleanup job for this site'
+cleanup.args = """"
+
+
 # Utilities for command-line script

 DEFAULT_ACTION_MAPPING = {
@@ -1212,6 +1226,7 @@
     'syncdb': syncdb,
     'validate': validate,
     'test':test,
+    'cleanup':cleanup,
 }

 NO_SQL_TRANSACTION = (
@@ -1223,6 +1238,7 @@
     'reset',
     'sqlindexes',
     'syncdb',
+    'cleanup',
 )

 class DjangoOptionParser(OptionParser):
@@ -1296,7 +1312,7 @@

     if action == 'shell':
         action_mapping[action](options.plain is True)
-    elif action in ('validate', 'diffsettings', 'dbshell'):
+    elif action in ('validate', 'diffsettings', 'dbshell', 'cleanup'):
         action_mapping[action]()
     elif action == 'syncdb':
         action_mapping[action](int(options.verbosity), options.interactive)
"	enhancement	closed	contrib.admin		normal	wontfix			Unreviewed	0	0	0	0	0	0
