Skip to content

[Error][Bug]adding silk middleware in MIDDLEWARE causes ImportError #108

Closed
@shahakshay94

Description

I followed the docs and tried to add the middleware line in different positions in MIDDLEWARE settings file, but I am getting "ImportError: No Module named context_processors"
Below is my full stack-trace of my error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
    return self.application(environ, start_response)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
    self.load_middleware()
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 44, in load_middleware
    mw_class = import_string(middleware_path)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/silk/middleware.py", line 32, in <module>
    fpath = silky_reverse('summary')
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/silk/middleware.py", line 23, in silky_reverse
    r = reverse('silk:%s' % name, *args, **kwargs)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 522, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 329, in app_dict
    self._populate()
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 269, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 372, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/akki/rest_api/rest_apis/urls.py", line 19, in <module>
    urlpatterns += patterns('', url(r'^silk/', include('silk.urls', namespace='silk')))
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 28, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/silk/urls.py", line 7, in <module>
    from silk.views.requests import RequestsView
  File "/home/akki/rest_api/venv/local/lib/python2.7/site-packages/silk/views/requests.py", line 1, in <module>
    from django.template.context_processors import csrf
ImportError: No module named context_processors
[03/May/2016 06:48:16] "GET /silk/ HTTP/1.1" 500 59

Below is my MIDDLEWARE settings:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'silk.middleware.SilkyMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions