13

No matter what I do, I simply cannot get django-debug-toolbar to appear. I've tried everything suggested in every answer on this question.

  • I have DEBUG=True in my settings
  • I have django.contrib.staticfiles and debug_toolbar in INSTALLED_APPS
  • I have 'debug_toolbar.middleware.DebugToolbarMiddleware' high up in MIDDLEWARE_CLASSES
  • I have INTERNAL_IPS = () in my settings
  • I tried adding print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR']) in a view, and it printed IP Address for debug-toolbar: 127.0.0.1
  • I have a closing </body></html> in my template
  • I have run pip install django-debug-toolbar in my virtualenv, without any issues
  • I have run python manage.py collectstatic and there is a debug_toolbar directory in my static files

When I run the app, I see no request in the console for any URLs containing django_debug_toolbar, so I suspect it's the application not being loaded.

I don't see any failed requests in the developer console, either.

I've read the django-debug-toolbar installation docs and am out of ideas.

Does anyone have any suggestions for debugging? I'm running OSX and Django 1.7. The curious thing is that debug-toolbar WAS appearing just fine - I think I've made some tweak that caused it to vanish, but I don't know what.

UPDATE: I've even tried adding this in my settings file, which is supposed to force the toolbar to appear:

def show_toolbar(request):
    return True
SHOW_TOOLBAR_CALLBACK = show_toolbar

But it doesn't help.

I've also tried throwing a deliberate exception in my view, so that I can check DEBUG is on and all the settings are as above. They are, and still no toolbar!

UPDATE 2: When I set INTERNAL_IPS=('127.0.0.1',), I start to see debug-toolbar requests in the console, but no toolbar on the page.

And the following HTML appears in my page - so the toolbar is there, but it's not visible because it's got display=none set all over it:

enter image description here

Community
  • 1
  • 1
Richard
  • 62,943
  • 126
  • 334
  • 542
  • So, interestingly, if I set `INTERNAL_IPS = ('127.0.0.1',)` in the settings, I start to see requests for `debug_toolbar` files in the console, and in DevTools in the browser. However, the toolbar itself is still invisible. Very odd. – Richard Mar 11 '15 at 10:46
  • Is there any kind of JS conflict in your browser console? It's also possibly a CSS conflict. – rnevius Mar 11 '15 at 10:47
  • Using "inspect element", I can see that the toolbar is there in the rendered HTML, but all its content panels have explicitly been set to `display: none`. Why could this be? – Richard Mar 11 '15 at 10:48
  • Have you removed the callback function from your settings? – rnevius Mar 11 '15 at 10:51
  • @rnevius yes, but it seems to make no difference whether it's there or not, it's the `INTERNAL_IPS` that makes the difference. – Richard Mar 11 '15 at 10:52
  • I have just found this suggestion http://stackoverflow.com/a/12340567/194000 but there are closing tags in the HTML, and the response has the header `Content-Type:text/html; charset=utf-8`. So I don't think it's that. – Richard Mar 11 '15 at 10:53
  • @rnevious in response to your earlier question, there are no errors in the console. – Richard Mar 11 '15 at 11:03
  • I see the problem...all of those things are supposed to be `display: none;`. I'll type up an answer. – rnevius Mar 11 '15 at 11:04
  • You may want to take a look at my code samples here regarding the IP issues http://stackoverflow.com/questions/42104980/how-do-i-get-django-debug-toolbar-to-only-display-on-my-ip-address-hosted-on-pyt/42105384#42105384 – Tim Feb 08 '17 at 21:56

6 Answers6

9

I had the same problem but managed to fix it following dvl's comment on this page. Here is a summary of the fix:

In settings.py

if DEBUG:
    MIDDLEWARE += (
        'debug_toolbar.middleware.DebugToolbarMiddleware',
    )
    INSTALLED_APPS += (
        'debug_toolbar',
    )
    INTERNAL_IPS = ('127.0.0.1', )
    DEBUG_TOOLBAR_CONFIG = {
        'INTERCEPT_REDIRECTS': False,
    }

In the project urls.py, add this url pattern to the end:

from django.conf import settings

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]
Greg Brown
  • 1,251
  • 1
  • 15
  • 32
7

Some information for news users as me, when dev on virtual or remote machine

Add this ligne in a views.py file

print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR'])

When the views is call, you can see the client IP in the shell

You have to add this IP the settings.py file INTERNAL_IPS = ('IP')

remy_dev
  • 195
  • 1
  • 12
4

All of the divs with display: none; are in fact behaving properly. They won't change to display: block; until you actually click on them in the toolbar itself.

The button used to toggle the toolbar is the div with an id="djDebugToolbarHandle". As you can see in your console, this button has a top position of 2310px. What this means is that it is rendering, but it is just way down off the page.

Try typing the following in the console to reset its position:

document.getElementById('djDebugToolbarHandle').style.top="30px";
rnevius
  • 26,578
  • 10
  • 58
  • 86
  • 1
    Woah! That works! Thank you SO much! I'll now dig around and try to find out why that style had been reset... – Richard Mar 11 '15 at 11:11
  • 1
    Yeah, that's a weird one. I'm glad my solution worked for you. – rnevius Mar 11 '15 at 11:12
  • There's some code in django-debug-toolbar that explicitly sets the `top` value: ob/7a82ac3b78099de4bd00fa4503cca9a699a80299/debug_toolbar/static/debug_toolbar/js/toolbar.js#L134-L152 I wonder if it's a bug in this? – Richard Mar 11 '15 at 11:15
  • Is that `2130px` value at all significant? Do you have that anywhere in your CSS or JS somewhere else in your app? – rnevius Mar 11 '15 at 11:15
  • I don't have that value anywhere else. Looking at the source code, the `top` value is supposed to get set when the user scrolls, though I hadn't been scrolling. I wonder if there's some nasty interaction with a browser plugin going on? – Richard Mar 11 '15 at 11:16
  • I'm getting a negative value for top, is it normal? – SalahAdDin Mar 02 '18 at 01:02
1

I had the same problem. Changing the finder module in my settings.py worked for me:

STATICFILES_FINDERS = (
    #'django.contrib.staticfiles.finders.FileSystemFinder', #THIS BREAKES debug_toolbar
    'django.contrib.staticfiles.finders.AppDirectoriesFinder', #THIS WORKS
)

Make sure to clean the browser cache after this change.

But after this, Django gave me error messages during collectstatic, due to this issue. I solved creating two configurations in my settings.py:

class Production(Base):
   DEBUG = False
   STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
   )

class Develop(Base):
   DEBUG = True
   STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
   )

I hope it helps.

  • I've lost so much time. There are many Information about another configuration but only your suggestion has worked for me. Thank you! – khashashin Oct 14 '20 at 18:09
1

One reason why django-debug-toolbar might appear but not appear correctly, (items stuck in "Loading") is if manage.py collectstatic has not been run. Just thought I'd post that here in case it helps someone.

0

i was have same issue with django-toolbar

all tags have class djdt-hidden and hidden

<div id="djDebug" class="djdt-hidden" dir="ltr" data-default-show="true">

i using pycharm and GoogleChrome

just using FireFox and it was fixed

hn_tired
  • 690
  • 10
  • 21