def validConnection():
    if django.db.connection.connection is None:
        django.db.connection.connection = django.db.connection.user.connection
return True

def close():
    django.db.connection.connection = None
django.db.connection._valid_connection = validConnection
django.db.connection.close = close
monkeyPatchDBConnection()

def setUserOnThisThread(user):
    pass
Per-session transactions in Django