33

I have a Django webapp. I have installed the debug_toolbar middleware and module. However, my webapps don't have the debug toolbar pull-out.

How do I actually see the debug toolbar? Is there something more I need to do? Do I need to use a particular template for my webapp? I have followed all the steps in the README, but that is not enough -- there seems to be some other dependency, or something else I'm missing.

Also, when looking at the set of URL patterns for my webapp, the debug prefix is not found among the recognized patterns. I've put a log in urls.py in debug_toolbar to make sure that modules is getting loaded by the activated debug_toolbar application, and it is.

This has me totally mystified, and I can find no Google or README on what to do to make this actually show up, or what the requirements are, so any pointer you can provide would be great!

Edit: It turns out, I was testing this with a SSH tunnel from the machine running the browser to the machine running the Django/Apache. In this case, the IP address actually seen for the remote machine was not what I thought it was, so the list of "good" IPs did not contain the browser's apparent remote machine. Fixing that fixed the problem!

azalea
  • 11,402
  • 3
  • 35
  • 46
Jon Watte
  • 6,579
  • 4
  • 53
  • 63
  • 4
    Does your html page have tag? Also you don't need put something in urls.py for debug-toolbar. UPD. Have you seen your page's source? – tony Jun 17 '11 at 18:49

1 Answers1

52
  1. As I know your HTML page must contain closed body tag, meta tag with content="text/html".

  2. I prefer the way when all debug-toolbar's settings separed from main settings. So try put in the end of settings.py something like

    #debug_toolbar settings
    if DEBUG:
        INTERNAL_IPS = ('127.0.0.1',)
        MIDDLEWARE_CLASSES += (
            'debug_toolbar.middleware.DebugToolbarMiddleware',
        )
    
        INSTALLED_APPS += (
            'debug_toolbar',
        )
    
        DEBUG_TOOLBAR_PANELS = [
            'debug_toolbar.panels.versions.VersionsPanel',
            'debug_toolbar.panels.timer.TimerPanel',
            'debug_toolbar.panels.settings.SettingsPanel',
            'debug_toolbar.panels.headers.HeadersPanel',
            'debug_toolbar.panels.request.RequestPanel',
            'debug_toolbar.panels.sql.SQLPanel',
            'debug_toolbar.panels.staticfiles.StaticFilesPanel',
            'debug_toolbar.panels.templates.TemplatesPanel',
            'debug_toolbar.panels.cache.CachePanel',
            'debug_toolbar.panels.signals.SignalsPanel',
            'debug_toolbar.panels.logging.LoggingPanel',
            'debug_toolbar.panels.redirects.RedirectsPanel',
        ]
    
        DEBUG_TOOLBAR_CONFIG = {
            'INTERCEPT_REDIRECTS': False,
        }
    

(Edit note: lapis updated the configs above to match the names used by the current (at the time of this update, 1.3.2) version of the Django Debug Toolbar. Per http://django-debug-toolbar.readthedocs.org/en/0.10.0/panels.html, the original versions (that used e.g. debug_toolbar.panels.sql.SQLDebugPanel vs debug_toolbar.panels.sql.SQLPanel as in 1.3.2) were correct when this question was original answered.)

(note: after Django 1.10, MIDDLEWARE_CLASSES should be MIDDLEWARE.)

xuhdev
  • 8,018
  • 2
  • 41
  • 69
tony
  • 1,506
  • 3
  • 21
  • 28
  • Thanks! That's good to know. It turned out my specific problem was different, but this is helpful, too! – Jon Watte Jun 18 '11 at 01:43
  • @Jon, what was your specific problem? Someone else might have the same problem and would benefit from a quick idea of what to check. – Jonathan Hartley Sep 10 '12 at 10:07
  • 3
    My actual problem is shown in the edit at the end of the post: Edit: It turns out, I was testing this with a SSH tunnel from the machine running the browser to the machine running the Django/Apache. In this case, the IP address actually seen for the remote machine was not what I thought it was, so the list of "good" IPs did not contain the browser's apparent remote machine. Fixing that fixed the problem! – Jon Watte Sep 11 '12 at 19:11
  • 7
    Adding the debug toolbar middleware at the bottom of the list may cause some issues. – hannson Mar 19 '13 at 14:33
  • 9
    Found this post and leaving a comment based on @JonWatte comment based on the solution here! Obvious in hindsight, but if you're running Django in a Docker (or other) container, you need to add the container's IP as an INTERNAL_IP. You can container inspect or you can throw `print(request.META['REMOTE_ADDR'])` in a view and see the console output to know your container's IP address. – Matt Pavelle Sep 15 '16 at 19:36
  • this helped me. Thank you – Gary Jan 20 '17 at 19:11