AttributeError 'User' object has no attribute 'session'

Raised by:

django/utils/functional.py (line 205)

Traceback (most recent call last):
  File "python3.5/site-packages/django/core/handlers/base.py", line 123, in get_response
    response = middleware_method(request)
  File "private.py", line 1, in private_function
    private_function()
  File "python3.5/site-packages/django/contrib/auth/__init__.py", line 133, in logout
    language = request.session.get(LANGUAGE_SESSION_KEY)
  File "python3.5/site-packages/django/utils/functional.py", line 205, in inner
    return func(self._wrapped, *args)
AttributeError: 'User' object has no attribute 'session'

How to reproduce

Try to pass a User to the logout function.

from django.contrib.auth import logout

logout(request.user)

How to fix

Passa Request object to the logout function.

from django.contrib.auth import logout

logout(request)