简体   繁体   English

Django Debug Toolbar没有出现

[英]Django Debug Toolbar doesn't appear

I think I have tried almost every solution on the web but the django debug toolbar still doesn't appear on my website. 我想我已经尝试了Web上几乎所有的解决方案,但是django调试工具栏仍然没有出现在我的网站上。 Difficult thing is that it doesn't give any error, or any sign from where I can find the issue. 困难的是,它不会发出任何错误,也没有从我可以发现问题的位置发出任何信号。

I have tried automatic as well as manual installation. 我尝试过自动以及手动安装。 Following most common things tried: 以下是最常见的尝试:

  1. added my ip to internal ips, even added SHOW_TOOLBAR_CALLBACK = lambda x: True 将我的IP添加到内部IP,甚至添加了SHOW_TOOLBAR_CALLBACK = lambda x: True

  2. Ran the collectstatic command 跑了collectstatic命令

  3. checked for any html tags not closing in my pages 检查是否有未关闭我页面的html标记

  4. Confirmed that debug=True in settings.py 确认settings.py中的debug=True

5) removed .pyc files 5)删除.pyc文件

And so on.. 等等..

EDIT TO INCLUDE SETTINGS 编辑以包括设置

Settings.py: Settings.py:

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)

DEBUG_TOOLBAR_PATCH_SETTINGS = False
SHOW_TOOLBAR_CALLBACK = lambda x: True
INTERNAL_IPS = ('bla','bla',)

myproject/myproject/urls.py: MyProject的/ myproject的/ urls.py:

if settings.DEBUG:
    import debug_toolbar
    urlpatterns += patterns('',
        url(r'^__debug__/', include(debug_toolbar.urls)),
    )

According to the docs of SHOW_TOOLBAR_CALLBACK , it's value is not expected to be a function object: 根据SHOW_TOOLBAR_CALLBACK的文档,它的值不应该是函数对象:

This is the dotted path to a function used for determining whether the toolbar should show or not. 这是用于确定工具栏是否应该显示的功能的虚线路径。

Ie try using a normal named function, and reference it with a string in your settings. 即尝试使用普通的命名函数,并在设置中使用字符串引用它。

Example, in your_project/config.py 例如,在your_project / config.py中

def show_always(request):
    return True

And then in settings: 然后在设置中:

SHOW_TOOLBAR_CALLBACK = 'your_project.config.show_always'

(Also, automatic setup did not work for me on one of two systems either, inexplicably; I had to use explicit setup , but you're doing that already.) (而且,莫名其妙地,自动设置对我来说在两个系统之一上也不起作用;我必须使用显式设置 ,但是您已经在这样做了。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM