2016-08-05 1 views
4

장고설치 : 형식 오류 : __init의 __은 (1 개) 위치 인수 만 2

장고 - 디버그 도구 모음 == 1.5

새로운 프로젝트 1.10 주어졌다 (나는했습니다 소요 방금 장고 설치). Django Debug Toolbar를 설치하려고합니다.

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

는 문서에 따르면, 장고 디버그 도구 모음이 릴리스의 장고 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 

답변

3

나는 MIDD에 미들웨어를 변경 settings.py의 LEWARE_CLASSES. 그것은 나를 위해 일합니다! 미들웨어의

+3

- 현재의 형태를, 당신의 대답은하지 않습니다 나머지 지역 사회가 당신이 그 문제를 풀거나 대답하기 위해 무엇을했는지 이해할 수 있도록 도와 줄 수있는 설명을하십시오. 특히, 이러한 설정이 어떻게 작동하는지 설명해야합니다. – ishmaelMakitla

+0

MIDDLEWARE를 MIDDLEWARE_CLASSES로 변경하면 MIDDLEWARE_CLASSES의 값이 무시됩니다. 이것은 경고입니다. 경고 : ? : (1_10.W001) MIDDLEWARE_CLASSES 설정은 장고 1.10에서 사용되지 않으며 MIDDLEWARE 설정이 우선합니다. MIDDLEWARE를 설정 했으므로 MIDDLEWARE_CLASSES의 값은 무시됩니다. 그것이 그가 그것을 실행할 수있는 이유입니다 ... 공식 문서 : https://docs.djangoproject.com/en/dev/releases/1.10/# new-style-middleware – RVE

10

장고 1.10 도입 된 새로운 스타일 :

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

는 변화와 관련된 a bug in django-debug-toolbar 있었다. 버그 is now fixed은 버전 1.6 이상이므로 latest version released to PyPI을 사용하십시오. 나중에 장고 1.10 장고 디버그 도구 모음이 지난 1.6 버전을 사용해야하는 경우


, 당신은 장고 설정에서 MIDDLEWARE_CLASSES에 미들웨어를 변경할 수 있습니다.

1

이미 고정되어 있습니다. MIDDLEWARE의 이름을 바꿀 필요가 없습니다. 그냥 자식에서 직접 설치 :

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

그리고 대신 stablelatest 문서 사용 : 당신은 정말이 일을해야하는 이유에 대한 일부 설명을 추가해야 http://django-debug-toolbar.readthedocs.io/en/latest/

+0

9 월 29 일부터 권장 [Explicit Setup] (http://django-debug-toolbar.readthedocs.io/en/stable/installation.html#explicit-setup)을 사용할 때, PyPI의 오래된'pip install' 버전은 작동하지 않습니다. 위와 같이 github에서 설치하면됩니다. – Jheasly

관련 문제