【问题标题】:unable to run server when django debug toolbar is enabled启用 django 调试工具栏时无法运行服务器
【发布时间】:2018-04-06 09:34:51
【问题描述】:

我们正在处理一个非常大的 django 代码库,我们正在使用 django 调试工具栏,问题很奇怪,如果我将 DEBUG_TOOLBAR=True 放在我的 django.settings 中,我将无法使用 manage.py 执行任何活动,例如python manage.py runserverpython manage.py collectstatic 任何一个。当我按CTRL+C 终止时,我无法,它卡在那里。这是我的 django 调试工具栏配置。

DEBUG=True
DEBUG_TOOLBAR = True
if DEBUG and DEBUG_TOOLBAR:
    INSTALLED_APPS += (
        'debug_toolbar',
    )
    INTERNAL_IPS = (
        '127.0.0.1',
        'XX.XX.XXX.XXX',
    )
    DEBUG_TOOLBAR_PANELS = [
            'debug_toolbar.panels.timer.TimerPanel',
            'debug_toolbar.panels.sql.SQLPanel',
            'debug_toolbar.panels.cache.CachePanel',
            'debug_toolbar.panels.signals.SignalsPanel',
            'debug_toolbar.panels.redirects.RedirectsPanel',
            ]
    DEBUG_TOOLBAR_CONFIG = {
        'RENDER_PANELS': True,
        'RESULTS_CACHE_SIZE': 2,
        'RESULTS_STORE_SIZE': 10, # Required for ddt_request_history
        'SHOW_TOOLBAR_CALLBACK': lambda request: True
            }

    MIDDLEWARE_CLASSES += (
        'saul.middleware.profile.ProfileMiddleware',
        'debug_toolbar.middleware.DebugToolbarMiddleware',
    )

但是,我已经完成了以下问题的答案,但都没有奏效。

django-debug-toolbar not showing up

【问题讨论】:

  • “无法”是什么意思?有错误信息吗?这是什么?
  • @AdamBarnes 上面没有错误信息....
  • 所以当输入python manage.py shell 并按下回车键时,你只得到一个光标而没有别的?没有错误,没有提示?如果您只输入 python 并按 Enter 会发生什么?
  • @AdamBarnes 甚至 shell 不工作...它不会打印任何错误,什么都没有...如果我输入 python 它会进入 python 控制台
  • 我的猜测是您的设置中某处有一个无限循环,这将导致 python 只是旋转并且在您使用管理命令时从不打印任何内容。您可以发布更多代码吗?如果项目不敏感,能不能放到github上给我们看看?

标签: python django django-debug-toolbar


【解决方案1】:

终于找到了答案,我们在多重设置文件中设置了DEBUG_TOOLBAR的无限循环,所以导致了那里的循环。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-07
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    相关资源
    最近更新 更多