django-debug-toolbar没有显示 [英] django-debug-toolbar not showing up

查看:339
本文介绍了django-debug-toolbar没有显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我做了以下操作来安装django-debug-toolbar:


  1. pip install django-debug-toolbar

  2. 添加到中间件类:

  3. <


      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',
    #取消注释下一行的简单点击保护:
    #'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',


    3添加INTERNAL_IPS:


    INTERNAL_IPS =('174.121.34 .187',)


    4将install_toolbar添加到已安装的应用程序中



    I没有任何错误或任何东西,工具栏不显示在任何页面,甚至不管理。



    我甚至将debug_toolbar模板的目录添加到我的 TEMPLATE_DIRS

    解决方案

    愚蠢的问题,但你没有提到,所以...什么是 DEBUG 设置为?它不会加载,除非它是 True



    如果仍然不起作用,请尝试添加127.0.0.1至 INTERNAL_IPS



    更新



    这是一个最后一个努力的举措,你不应该这样做,但它会清楚地显示是否只有一些配置问题或是否有更大的问题。



    将以下内容添加到settings.py:

      def show_toolbar请求):
    返回True
    SHOW_TOOLBAR_​​CALLBACK = show_toolbar

    这将有效地删除所有通过调试工具栏进行检查,以确定是否应该或不应该自己加载;它将永远只是加载。只有在出于测试的目的,如果您忘记并启动它,您的所有访问者都将看到您的调试工具栏。



    对于显式配置,还可以看到官方安装文档此处



    EDIT(6/17/2015):



    显然,核选项的语法已更改。它现在在自己的字典中:

      def show_toolbar(request):
    return True
    DEBUG_TOOLBAR_​​CONFIG = {
    SHOW_TOOLBAR_​​CALLBACK:show_toolbar,
    }

    他们的测验使用此字典。


    I looked at other questions and can't figure it out...

    I did the following to install django-debug-toolbar:

    1. pip install django-debug-toolbar
    2. added to middleware classes:

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

    3 Added INTERNAL_IPS:

    INTERNAL_IPS = ('174.121.34.187',)

    4 Added debug_toolbar to installed apps

    I am not getting any errors or anything, and the toolbar doesn't show up on any page, not even admin.

    I even added the directory of the debug_toolbar templates to my TEMPLATE_DIRS

    解决方案

    Stupid question, but you didn't mention it, so... What is DEBUG set to? It won't load unless it's True.

    If it's still not working, try adding '127.0.0.1' to INTERNAL_IPS as well.

    UPDATE

    This is a last-ditch-effort move, you shouldn't have to do this, but it will clearly show if there's merely some configuration issue or whether there's some larger issue.

    Add the following to settings.py:

    def show_toolbar(request):
        return True
    SHOW_TOOLBAR_CALLBACK = show_toolbar
    

    That will effectively remove all checks by debug toolbar to determine if it should or should not load itself; it will always just load. Only leave that in for testing purposes, if you forget and launch with it, all your visitors will get to see your debug toolbar too.

    For explicit configuration, also see the official install docs here.

    EDIT(6/17/2015):

    Apparently the syntax for the nuclear option has changed. It's now in its own dictionary:

    def show_toolbar(request):
        return True
    DEBUG_TOOLBAR_CONFIG = {
        "SHOW_TOOLBAR_CALLBACK" : show_toolbar,
    }
    

    Their tests use this dictionary.

    这篇关于django-debug-toolbar没有显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆