2

We installed the django toolbar yesterday on our remote server and have been trying for it to show on the page itself. I have gone through all the questions here and on google about it and have all the settings the way they are suppose to be. Like the INTERNAL_IPS, DEBUG, MIDDLEWARE_CLASSES etc. The toolbar code is showing up in the source html but I cant see any buttons on the screen. I m ready to pull my hair out on this thing. Please help! Below I m pasting the toolbar code that is showing up before my tag in the html.

<script type="text/javascript">
// <![CDATA[
var DEBUG_TOOLBAR_MEDIA_URL = "/__debug__/m/";
// ]]>
</script>
<script type="text/javascript" src="/__debug__/m/js/toolbar.min.js"></script>
<div id="djDebug" style="display:none;">
<div style="display:none;" id="djDebugToolbar">
    <ul id="djDebugPanelList">
    <li><a id="djHideToolBarButton" href="#" title="Hide Toolbar">Hide &raquo;   </a></li>
            <li>
            <a href="#" title="Versions" class="djDebugVersionPanel">
            Versions
            <br /><small>Django 1.4</small>
            </a>
            </li>
            <li>
            <a href="#" title="Resource Usage" class="djDebugTimerPanel">
                Time
            <br /><small>CPU: 220.01ms (251.44ms)</small>

EDIT: I m adding the settings.py part of my app:

if DEBUG:
INTERNAL_IPS = ('my machine's IP',)
MIDDLEWARE_CLASSES += (
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)

INSTALLED_APPS += (
    'debug_toolbar',
)

DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    #'debug_toolbar.panels.profiling.ProfilingDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.cache.CacheDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.logger.LoggingPanel',
)

DEBUG_TOOLBAR_CONFIG = {
    'INTERCEPT_REDIRECTS': False,
}

def show_toolbar(request):
    return True # Always show toolbar, for example purposes only.

DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TOOLBAR_CALLBACK': show_toolbar,
 # 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
'HIDE_DJANGO_SQL': False,
#  'TAG': 'html',
'DEBUG_TOOLBAR_MEDIA_URL' : '/usr/local/lib/python2.6/dist-packages/django_debug_toolbar-0.8.5-py2.6.egg/debug_toolbar/media'       
    }
us1415
  • 83
  • 2
  • 9
  • 2
    In page source, right before the snippet you pasted, there should be a `style` tag with big chunk of CSS for debug toolbar. Is it there? If it is, take a look with WebKit inspector, maybe some of your own CSS declarations are interfering with debug toolbar's ones and hiding it or pushing it off-screen? – Pēteris Caune Jun 12 '12 at 11:45
  • I looked but there isnt any CSS for the toolbar. Clicking on the JavaScript file src link src="/__debug__/m/js/toolbar.min.js"> takes me to a not found page though. Dont know if that matters. – us1415 Jun 12 '12 at 12:32
  • I think it matters. If debug mode is activated, you should see the django debug 404 page with a list of routes. Can you routes related to the debug toolbar in the list ? – madjar Jun 12 '12 at 12:36
  • Yep. Saw the page that it cant find the url in the list of mysite.urls. I thought the toolbar url.py was suppose to take care of it. Do I need to do something here? – us1415 Jun 12 '12 at 12:41
  • Here is what I see when I get a django page not found (404): The current URL, __debug__/sql_explain/, didn't match any of these. – us1415 Jun 12 '12 at 12:53

5 Answers5

2

This is a wild guess, but I've had this problem before : your html code is not correct. I think I had a missing tag that prevented the debug toolbar from displaying but that otherwise was not a problem.

Disable the debug toolbar and check that you page is correct (use the w3c validator, for example). If you find any html issues, correct it. It might make the debug toolbar work again.

madjar
  • 12,691
  • 2
  • 44
  • 52
  • Thanks. I checked but they are all minor issues like not using
    instead of
    . I corrected them but still no joy.
    – us1415 Jun 12 '12 at 12:31
  • No problem. Thanks for trying though. Another point here. I have tried to use the jQuery .show method to change the value of the none here to block and the debug tool data shows up at the end of the page. Here is the one that I m changing in my base.html to show the data. – us1415 Jun 12 '12 at 12:43
  • I m suspecting that there is an issue with the media files (js, css, images) that its not showing up. The path for the media files is: /usr/local/lib/python2.6/dist-packages/django_debug_toolbar-0.8.5-py2.6.egg/debug_toolbar/media. Am I suppose to do something in the settings.py file to show the debug bar where the media files are or something? – us1415 Jun 12 '12 at 12:45
  • Just in case: is 'debug_toolbar' in INSTALLED_APPS? Looks like its static files are not being picked up by Django. If you load e.g. `http://yourserver:port/__debug__/m/js/toolbar.min.js` in browser, you should get a chunk of JS. – Pēteris Caune Jun 12 '12 at 13:11
  • Yep. Sure is: INSTALLED_APPS += ( 'debug_toolbar', ) This is what I get: The current URL, __debug__/m/js/toolbar.min.js, didn't match any of these. So, I m not getting the JS or any thing in the media folder. What can I do to make sure that the app can get to the toolbar media files. – us1415 Jun 12 '12 at 13:24
  • I have also edited my question to add the settings.py part of toolbar. – us1415 Jun 12 '12 at 13:30
  • I've never specified ``DEBUG_TOOLBAR_MEDIA_URL`` before. Are you sure this is needed, and that it isn't the source of the problem ? – madjar Jun 12 '12 at 13:35
  • I added it to see if it would make a difference. Removing it doesnt change anything. Also, removed the duplicate DEBUG_TOOLBAR_CONFIG – us1415 Jun 12 '12 at 13:37
  • Latest version of debug toolbar is 0.9.4 It's worth a shot to upgrade--maybe a bug was fixed sometime along the way. Also, try putting some `print`s in `debug_toolbar/loader.py`, `render_toolbar` function to see if `media_path` looks right – Pēteris Caune Jun 12 '12 at 13:39
  • I installed the toolbar using the easy install. How can I upgrade to 0.9.4? Is there an easy install function that I can use? Also, what should I put for the print statements in the loader.py? I see the `'MEDIA_URL': u'%s/__debug__/m/' % base_url` in the file. Should I change it? – us1415 Jun 12 '12 at 13:43
  • try `easy_install django_debug_toolbar==0.9.4` – Pēteris Caune Jun 12 '12 at 13:51
  • That was it. Upgrading to 0.9.4 did it. I can now see the toolbar. Thanks Peteris. Can you please post this as an answer so I could accept it? – us1415 Jun 12 '12 at 13:57
2

The meaning of SHOW_TOOLBAR_CALLBACK have changed to require a string and not support a callable.

def custom_show_toolbar(request):
    return True  # Always show toolbar, for example purposes only.

DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': 'your_project_name.settings.custom_show_toolbar',
}
hahakubile
  • 6,978
  • 4
  • 28
  • 18
1

Latest version of debug toolbar is 0.9.4 It's worth a shot to upgrade--maybe a bug was fixed sometime along the way.

Pēteris Caune
  • 43,578
  • 6
  • 59
  • 81
  • Should have though about it. I also have had this problem. – madjar Jun 12 '12 at 14:32
  • 1
    My issue was : not running collectstatic after debug_toolbar installation. My static goes to S3 buckets, so none of the javascripts were actually there. – kert Sep 04 '14 at 00:17
0

Including other things, you need to confirm the following lines in settings.py file:

mimetypes
mimetypes.add_type("application/javascript", ".js", True)
DJANGO_DEBUG = True
0

In Windows, search registry and edit the registry under HKEY_CLASSES_ROOT.js\Content Type from text/plain to text/javascript

Also clear your browser cache and reload.

Watch this video it will help. https://youtu.be/45bluSqKqNE

Mani
  • 1
  • 1