Ticket #4427: daily_cleanup.3.patch

File daily_cleanup.3.patch, 850 bytes (added by nick.lane.au@…, 17 years ago)

The right way round this time...

  • django/bin/daily_cleanup.py

     
    77sessions at the moment).
    88"""
    99
    10 from django.db import backend, connection, transaction
     10import datetime
     11from django.db import transaction
     12from django.contrib.sessions.models import Session
     13
    1114
    1215def clean_up():
    13     # Clean up old database records
    14     cursor = connection.cursor()
    15     cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
    16         (backend.quote_name('django_session'), backend.quote_name('expire_date')))
     16    # Clean up expired sessions.
     17    Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
    1718    transaction.commit_unless_managed()
    1819
    1920if __name__ == "__main__":
Back to Top