'Django: ImportError: No module named doc

here is the traceback

System check identified 1 issue (0 silenced).
September 10, 2018 - 13:01:31
Django version 1.8, using settings 'settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
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/basha/UpgradeMloss/venv1.8/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
    self.load_middleware()
  File "/home/basha/UpgradeMloss/venv1.8/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 50, in load_middleware
    mw_class = import_string(middleware_path)
  File "/home/basha/UpgradeMloss/venv1.8/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)
ImportError: No module named doc

and here is the installed libraries pip freeze:

certifi==2018.8.24
chardet==3.0.4
Django==1.8
django-contrib-comments==1.5
django-markup-deprecated==0.0.3
django-recaptcha2==1.3.0
idna==2.7
Markdown==2.6.11
Pillow==5.2.0
pytz==2018.5
recaptcha-client==1.0.6
requests==2.19.1
urllib3==1.23

and here is also the INSTALLED_APPS:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'django_comments',
    'django.contrib.syndication',
    'django.contrib.flatpages',
    'django.contrib.humanize',
    'software',
    'revision',
    'registration',
    'community',
    'forshow',
    'user',
    'subscriptions2',
    'aggregator',
    'blog',
    'captcha',
    'snowpenguin.django.recaptcha2',
    'markup_deprecated',
)

I don't know exactly where is the problem or how can I resolve it. I've been searching about this ImportError but there is nothing talking about such an error.!



Solution 1:[1]

In some deprecated elements have been removedĀ [Django-doc]:

  • django.middleware.doc.XViewMiddleware will be removed. Use django.contrib.admindocs.middleware.XViewMiddleware instead.

So in your MIDDLEWARE_CLASSES, you should replace it with:

# settings.py

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.admindocs.middleware.XViewMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

In later versions MIDDLEWARE_CLASSES is renamed to MIDDLEWARE. If you upgrade the Django version, I advise you to check the deprecation page and make changes accordingly. Usually an item is marked deprecated two versions before it is removed. So it was marked deprecated in .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1