Django-debug-toolbar: Django 디버그 도ꡬ λͺ¨μŒ 1.8을 μ‚¬μš©ν•  λ•Œ μŠ€νƒ μ˜€λ²„ν”Œλ‘œ(1.7μ—μ„œ μ œλŒ€λ‘œ μž‘λ™)

에 λ§Œλ“  2017λ…„ 06μ›” 01일  Β·  11μ½”λ©˜νŠΈ  Β·  좜처: jazzband/django-debug-toolbar

μ•ˆλ…•ν•˜μ„Έμš”. Wagtail CMSμ—μ„œ μ œκ³΅ν•˜λŠ” κ²½λ‘œμ—μ„œ DJDT 1.8을 μ‚¬μš©ν•˜λ €κ³  ν•˜λ©΄ μŠ€νƒ μ˜€λ²„ν”Œλ‘œ 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€. λ™μΌν•œ 경둜/νŽ˜μ΄μ§€κ°€ DJDT 1.7μ—μ„œ μž‘λ™ν•©λ‹ˆλ‹€. μ €λŠ” Django 1.11.2와 Wagtail 1.10.1을 μ‹€ν–‰ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. λ‹€μŒμ€ μΆ”μ μž…λ‹ˆλ‹€.

Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00007f5d3f7f8700 (most recent call first):
  File "/venv-path/django/utils/functional.py", line 215 in wrapper
  File "/venv-path/django/template/base.py", line 835 in __init__
  File "/venv-path/django/template/base.py", line 685 in __init__
  File "/venv-path/django/template/base.py", line 600 in compile_filter
  File "/venv-path/django/template/defaulttags.py", line 826 in do_for
  File "/venv-path/django/template/base.py", line 513 in parse
  File "/venv-path/django/template/base.py", line 230 in compile_nodelist
  File "/venv-path/django/template/base.py", line 191 in __init__
  File "/venv-path/django/template/loaders/base.py", line 44 in get_template
  File "/venv-path/django/template/engine.py", line 136 in find_template
  File "/venv-path/django/template/engine.py", line 162 in get_template
  File "/venv-path/django/template/backends/django.py", line 39 in get_template
  File "/venv-path/django/template/loader.py", line 21 in get_template
  File "/venv-path/django/template/loader.py", line 67 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  File "/venv-path/django/template/backends/django.py", line 66 in render
  File "/venv-path/django/template/loader.py", line 68 in render_to_string
  File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
  File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
  File "/venv-path/django/utils/encoding.py", line 76 in force_text
  File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
  File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
  File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
  File "/venv-path/django/template/base.py", line 207 in render
  ...

Thread 0x00007f5d4bcb3700 (most recent call first):
  File "/usr/lib64/python3.5/selectors.py", line 376 in select
  File "/usr/lib64/python3.5/socketserver.py", line 232 in serve_forever
  File "/venv-path/django/core/servers/basehttp.py", line 174 in run
  File "/venv-path/django/core/management/commands/runserver.py", line 149 in inner_run
  File "/venv-path/django/utils/autoreload.py", line 227 in wrapper

Thread 0x00007f5d61887740 (most recent call first):
  File "/venv-path/django/utils/autoreload.py", line 281 in reloader_thread
  File "/venv-path/django/utils/autoreload.py", line 298 in python_reloader
  File "/venv-path/django/utils/autoreload.py", line 332 in main
  File "/venv-path/django/core/management/commands/runserver.py", line 110 in run
  File "/venv-path/django/core/management/commands/runserver.py", line 101 in handle
  File "/venv-path/django/core/management/base.py", line 330 in execute
  File "/venv-path/django/core/management/commands/runserver.py", line 62 in execute
  File "/venv-path/django/core/management/base.py", line 283 in run_from_argv
  File "/venv-path/django/core/management/__init__.py", line 355 in execute
  File "/venv-path/django/core/management/__init__.py", line 363 in execute_from_command_line
  File "manage.py", line 15 in <module>
Aborted

μ§€κΈˆμ€ 1.7을 μ‹€ν–‰ν•˜λŠ” 데 λ¬Έμ œκ°€ μ—†μ§€λ§Œ 이 문제λ₯Ό μ–΄λ””μ„œλΆ€ν„° νŒŒν—€μ³μ•Ό 할지 λ§‰λ§‰ν•©λ‹ˆλ‹€. μ–΄λ–€ 아이디어, μ‘°μ–Έ λ˜λŠ” 희망적인 μ†”λ£¨μ…˜μ΄ μžˆμŠ΅λ‹ˆκΉŒ? 미리 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

https://github.com/wagtail/wagtail/issues/2874... 와 관련이 μžˆμ„ 수

λͺ¨λ“  11 λŒ“κΈ€

Django 1.8μ—μ„œ DDT 1.8을 μ‚¬μš©ν•  λ•Œλ„ λ™μΌν•œ 문제λ₯Ό 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

λ™μΌν•œ 문제λ₯Ό λ³΄μ•˜μŠ΅λ‹ˆλ‹€. ν…œν”Œλ¦Ώμ„ μ§€μ •ν•œ StreamField 블둝을 μ‚¬μš©ν•  λ•Œ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. SKIP_TEMPLATE_PREFIXES 디버그 도ꡬ λͺ¨μŒ ꡬ성에 ν•΄λ‹Ή ν…œν”Œλ¦Ώμ„ μΆ”κ°€ν•˜λŠ” 것이 ν•΄κ²° λ°©λ²•μ΄μ—ˆμŠ΅λ‹ˆλ‹€. (μ–Όλ§ˆ μ „μ΄μ§€λ§Œ) κ·Όλ³Έ λ¬Έμ œλŠ” 블둝 κ°œμ²΄κ°€ __str__ λ©”μ„œλ“œμ—μ„œ ν…œν”Œλ¦Ώμ„ λ Œλ”λ§ν•˜μ—¬ 디버그 도ꡬ λͺ¨μŒμ˜ TEMPLATES νŒ¨λ„μ—μ„œ λ¬΄ν•œ μž¬κ·€κ°€ λ°œμƒν–ˆλ‹€λŠ” κ²ƒμž…λ‹ˆλ‹€.

@gasman λ‚˜λŠ” 당신이 이 문제λ₯Ό 보고 μ‹Άμ–΄ν•  것이라고 μƒκ°ν–ˆμŠ΅λ‹ˆλ‹€.

https://github.com/wagtail/wagtail/issues/2874... 와 관련이 μžˆμ„ 수

λ‚˜λŠ” DDT 1.8, Django 1.11.2 및 Wagtail 1.10.1μ—μ„œ 같은 것을 κ²½ν—˜ν–ˆμŠ΅λ‹ˆλ‹€.
Python 3.6, 3.6.1 및 3.7a둜 μž¬ν˜„ν–ˆμŠ΅λ‹ˆλ‹€.

λͺ‡ 가지 쑰사λ₯Ό ν•œ ν›„, panel.py:128 에 λ¬΄ν•œ 루프가 μƒμ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€. Wagtail의 경우 μ—¬κΈ° value λŠ” StructValue κ°€ 될 수 μžˆμŠ΅λ‹ˆλ‹€. μ—¬κΈ°μ„œ λ¬Έμžμ—΄ ν‘œν˜„μ€ μ‹€μ œλ‘œ template_rendered μ‹ ν˜Έλ₯Ό νŠΈλ¦¬κ±°ν•˜λŠ” ν…œν”Œλ¦Ώ λ Œλ”λ§μž…λ‹ˆλ‹€. .

Wagtail을 μ‚¬μš©ν•˜λŠ” μ‚¬λžŒλ“€μ„ μœ„ν•΄ μ›μˆ­μ΄ 패치λ₯Ό ν–ˆμŠ΅λ‹ˆλ‹€. νŒ¨μΉ˜λŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

https://github.com/FlipperPA/django-debug-toolbar/commit/e68cfa509566bf5332c37f03c0fd9753a873d491

Wagtail μ „μš©μ΄κΈ° λ•Œλ¬Έμ— 이것이 PR이 λ˜μ–΄μ•Ό ν•œλ‹€κ³  μƒκ°ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

이에 λŒ€ν•œ 또 λ‹€λ₯Έ ν•«ν”½μŠ€λŠ” 디버그 도ꡬ λͺ¨μŒμ—μ„œ StructBlock μ—μ„œ μ‚¬μš©ν•˜λŠ” ν…œν”Œλ¦Ώμ„ μ œμ™Έν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. 예

class MyStructBlock(StructBlock):
    ...
    class Meta:
        ...
        template = 'myblocks/structblock.html'

그리고 settings.py νŒŒμΌμ— μΆ”κ°€:

DEBUG_TOOLBAR_CONFIG = {
    'SKIP_TEMPLATE_PREFIXES': ('django/forms/widgets/', 'admin/widgets/', 'myblocks/structblock.html'),
}

SKIP_TEMPLATE_PREFIXES λŒ€ν•œ DDT λ¬Έμ„œμ—μ„œ:

μ΄λŸ¬ν•œ λ¬Έμžμ—΄λ‘œ μ‹œμž‘ν•˜λŠ” ν…œν”Œλ¦Ώμ€ λ Œλ”λ§λœ ν…œν”Œλ¦Ώ 및 μ»¨ν…μŠ€νŠΈλ₯Ό μˆ˜μ§‘ν•  λ•Œ κ±΄λ„ˆλœλ‹ˆλ‹€. νŒ¨λ„ HTML은 λ§Žμ€ 양식 ν•„λ“œμ™€ λ§Žμ€ μ˜΅μ…˜μ„ μ‚¬μš©ν•˜μ—¬ 수백 λ©”κ°€λ°”μ΄νŠΈκΉŒμ§€ μ‰½κ²Œ ν™•μž₯될 수 μžˆμœΌλ―€λ‘œ ν…œν”Œλ¦Ώ 기반 양식 μœ„μ ―μ€ 기본적으둜 κ±΄λ„ˆλœλ‹ˆλ‹€.

λ‚˜λ₯Ό μœ„ν•΄ μž‘λ™ν•©λ‹ˆλ‹€.

Django Debug Toolbar 1.8 및 django-floppyformsμ—μ„œ 이 λ¬Έμ œκ°€ μžˆμ—ˆκ³  λΉ„μŠ·ν•œ λ°©μ‹μœΌλ‘œ 이 문제λ₯Ό μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€.

DEBUG_TOOLBAR_CONFIG = {
    'SKIP_TEMPLATE_PREFIXES': (
        'django/forms/widgets/',
        'admin/widgets/',
        'floppyforms/'
    ),
    'DISABLE_PANELS': {
        'debug_toolbar.panels.redirects.RedirectsPanel',
        'debug_toolbar.panels.redirects.TemplatesPanel'
    },
}

λ˜ν•œ νŽ˜μ΄μ§€ 속도가 많이 λŠλ €μ§€κΈ° λ•Œλ¬Έμ— 기본적으둜 TemplatesPanel을 λΉ„ν™œμ„±ν™”ν•˜κΈ°λ‘œ κ²°μ •ν–ˆμŠ΅λ‹ˆλ‹€. νŽ˜μ΄μ§€ λ‘œλ“œλŠ” Django Debug Toolbar 1.7에 λΉ„ν•΄ 3λ°° λŠλ ΈμŠ΅λ‹ˆλ‹€.

https://github.com/wagtail/wagtail/pull/3738 μ—μ„œ μˆ˜μ •λ¨ - Wagtail λ¬Έμ œμ΄λ―€λ‘œ 닫을 수 μžˆλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

@gasmanλ‹˜ κ°μ‚¬ν•©λ‹ˆλ‹€!

django-el-pagination==3.1.0 에도 영ν–₯을 미치며 'el_pagination/', λ₯Ό SKIP_TEMPLATE_PREFIXES ν•˜λ©΄ 도움이 λ©λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰