'Removes the authenticated user\'s cookies and session object.
Causes the authenticated user to be logged out.'

def logout(self):

    request = HttpRequest()
    engine = import_module(settings.SESSION_ENGINE)
    UserModel = get_user_model()
    if self.session:
        request.session = self.session
        uid = self.session.get(u'_auth_user_id')
        if uid:
            request.user = UserModel._default_manager.get(pk=uid)
    else:
        request.session = engine.SessionStore()
    logout(request)
    self.cookies = SimpleCookie()
