Setting the Django Debug toolbar: TypeError: __init __ () takes 1 positional argument, but 2 are given

Django 1.10

Django-debugging tools == 1.5

New project (I just installed Django). Trying to install Django Debug toolbar.

Documentation: https://django-debug-toolbar.readthedocs.io/en/stable/installation.html#prerequisites

According to the documentation, this version of the django-debug toolbar is compatible with Django 1.10.

Could you help me understand what I did wrong.

settings.py

# { django-debug-toolbar
DEBUG_TOOLBAR_PATCH_SETTINGS = False
INTERNAL_IPS = ['127.0.0.1', ]
if DEBUG:
    MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware',]
    INSTALLED_APPS += ['debug_toolbar',]
# } django-debug-toolbar

urls.py

from django.conf import settings
from django.conf.urls import include
if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]

Traceback

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f97d6ab9840>
Traceback (most recent call last):
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run
    handler = self.get_handler(*args, **options)
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
    handler = super(Command, self).get_handler(*args, **options)
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
    return get_internal_wsgi_application()
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
    return import_string(app_path)
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
    module = import_module(module_path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/michael/workspace/photoarchive/photoarchive/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
    return WSGIHandler()
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
    self.load_middleware()
  File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/handlers/base.py", line 82, in load_middleware
    mw_instance = middleware(handler)
TypeError: __init__() takes 1 positional argument but 2 were given
+4
source share
3 answers

Django 1.10 introduced a new style of middleware:

https://docs.djangoproject.com/en/1.10/releases/1.10/#new-style-middleware

django-debug-toolbar, . ​​ 1.6 , , PyPI.


django-debug-toolbar 1.6 Django 1.10 , MIDDLEWARE MIDDLEWARE_CLASSES Django.

+10

MIDDLEWARE MIDDLEWARE_CLASSES settings.py. !

+3

. MIDDLEWARE. git:

pip install https://github.com/jazzband/django-debug-toolbar/archive/master.zip

stable latest docs: http://django-debug-toolbar.readthedocs.io/en/latest/

+1

Source: https://habr.com/ru/post/1650322/


All Articles