Django middleware 'module' object is not callable
<p>I have problem with middleware I found a lot of questions about it but nothing help in my case.</p>

<p>I use middleware to get current_user to use in my model to save modified user in save method without write this in view.</p>

<p>Here is <a href="https://stackoverflow.com/questions/862522/django-populate-user-id-when-saving-a-model">original post</a> with this code: </p>

<p><strong>Middleware</strong></p>

<pre><code>from threading import local

_user = local()


class CurrentUserMiddleware(object):
    def process_request(self, request):
        _user.value = request.user


def get_current_user():
    return _user.value
</code></pre>

<p><strong>There is something wrong in this code because I'm getting error like:</strong></p>

<pre><code>Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\Lib\wsgiref\handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\contrib\staticfiles\handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\handlers\wsgi.py", line 158, in __call__
    self.load_middleware()
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\handlers\base.py", line 53, in load_middleware
    mw_instance = mw_class()
TypeError: 'module' object is not callable
[20/Jul/2016 10:51:44] "GET /panel/ HTTP/1.1" 500 59
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python35-32\Lib\wsgiref\handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\contrib\staticfiles\handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\handlers\wsgi.py", line 158, in __call__
    self.load_middleware()
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\handlers\base.py", line 53, in load_middleware
    mw_instance = mw_class()
TypeError: 'module' object is not callable
[20/Jul/2016 10:51:44] "GET /favicon.ico HTTP/1.1" 500 59
</code></pre>

<p><strong>My middleware settings:</strong></p>

<pre><code>MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.gzip.GZipMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'reversion.middleware.RevisionMiddleware',
    'task.current_user',
)
</code></pre>

<p>Can you give me some advice where is error or something? I don't have any other idea to try so I hope that you have some.</p>