gpt4 book ai didi

django-debug-toolbar - Django Debug Toolbar : TypeError: __init__() takes 1 positional argument but 2 were given的安装

转载 作者:行者123 更新时间:2023-12-04 08:22:39 26 4
gpt4 key购买 nike

Django 1.10

django-debug-toolbar == 1.5

新项目(我刚刚安装了Django)。尝试安装Django调试工具栏。

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

根据文档,此版本的django-debug-toolbar与Django 1.10兼容。

您能帮我了解我做错了什么吗?

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)),
]

追溯
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

最佳答案

Django 1.10引入了新的中间件样式:

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

a bug in django-debug-toolbar与该更改有关。 1.6或更高版本中的is now fixed错误,因此只需使用latest version released to PyPI即可。

如果必须在Django 1.10或更高版本上使用django-debug-toolbar的版本早于1.6,则可以在Django设置中将MIDDLEWARE更改为MIDDLEWARE_CLASSES。

关于django-debug-toolbar - Django Debug Toolbar : TypeError: __init__() takes 1 positional argument but 2 were given的安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38792686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com