Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Debug Toolbar Install Problems

I am having issues trying to get the django-debug-toolbar up and running. I have all of the necessary info added to INSTALLED_APPS, MIDDLEWARE_CLASSES, and my ip is in the INTERNAL_IPS tuple. I have run the setup.py script and everything seems to load fine as I am getting no errors from django or apache.

However, nothing happens - no toolbar on any pages, has anyone else ever seen this behavior? Am I missing something obvious?

like image 434
HurnsMobile Avatar asked Feb 17 '11 21:02

HurnsMobile


2 Answers

I had this same issue for awhile.

Have you tried logging into the admin panel? If the toolbar displays there, but does not display in your code, it's very likely that you are missing the opening and closing tags in your template. By default, django debug toolbar attaches to the BODY tag, though you can change this behavior if you desire. See this question: Django Debug Toolbar Only Working for Admin Section

like image 110
Andrew Parker Avatar answered Oct 08 '22 07:10

Andrew Parker


I'd either do one of 2 things:

insert import pdb; pdb.set_trace() at the middleware _show_toolbar method and see which item it fails on, or pepper the middleware with print statements to see which check it failed on, whichever you're more comfortable with.

def _show_toolbar(self, request, response=None):
        if not settings.DEBUG or not getattr(settings, 'DEBUG_TOOLBAR', True) or getattr(settings, 'TEST', False):
            return False

        if request.path.startswith(settings.MEDIA_URL):
            return False

        if response:
            if getattr(response, 'skip_debug_response', False):
                return False
            if response.status_code >= 300 and response.status_code < 400:
                return False

        # Allow access if remote ip is in INTERNAL_IPS or
        # the user doing the request is logged in as super user.
        if (not request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 
           (not request.user.is_authenticated() or not request.user.is_superuser)):
            return False
        return True
like image 43
Yuji 'Tomita' Tomita Avatar answered Oct 08 '22 06:10

Yuji 'Tomita' Tomita