diff --git a/AUTHORS b/AUTHORS index fedbd74684..fde35507a0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -142,6 +142,7 @@ answer newbie questions, and generally made Django that much better: Joseph Kocherhans konrad@gwu.edu lakin.wecker@gmail.com + Nick Lane Stuart Langridge Nicola Larosa Eugene Lazutkin diff --git a/django/bin/daily_cleanup.py b/django/bin/daily_cleanup.py index 3b83583d73..c87be1e4c3 100644 --- a/django/bin/daily_cleanup.py +++ b/django/bin/daily_cleanup.py @@ -7,13 +7,13 @@ Can be run as a cronjob to clean out old data from the database (only expired sessions at the moment). """ -from django.db import backend, connection, transaction +import datetime +from django.db import transaction +from django.contrib.sessions.models import Session def clean_up(): - # 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'))) + """Clean up expired sessions.""" + Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() transaction.commit_unless_managed() if __name__ == "__main__":