Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Django ORM Same Old ORM django-debug-toolbar

Adam Cameron
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Adam Cameron
Python Web Development Techdegree Graduate 16,731 Points

Toolbar only showing up in my local environment when I add Workspaces-specific code?

I followed the django-debug-toolbar installation instructions exactly (they're simple enough, right??) but the toolbar wouldn't show up. I monkeyed around with the positioning of 'debug_toolbar.middleware.DebugToolbarMiddleware' in MIDDLEWARE_CLASSES a bunch because the docs suggested there could be an issue there but that didn't solve anything. So on a whim I tried adding the stuff in settings.py that Kenneth says is only if you're on Workspaces, and the toolbar showed up! Any idea why this might be??

1 Answer

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,610 Points

Assuming you have done something like (below)

def show_debug_toolbar(request):
    return True

# EXAMPLE
# if my settings.py file was located in a 'project_8' folder.
# 
DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': 'project_8.settings.show_debug_toolbar'
}

or Kenneths way

DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': lambda x: True
}

and it still hasnt worked I would start asking a few other prereq questions such as.

  1. Is 'debug_toolbar' in your INSTALLED_APPS
  2. Does your projects urls.py contain the following?
# urls.py (project level)
# the urls.py, in same folder as wsgi.py

# make sure this is at the top.
from django.conf import settings

# urlpatterns = [
    # keep your other urls here..
# ]

# at the bottom add these lines. under your other urlpatterns.
if settings.DEBUG:
    import debug_toolbar
    urlpatterns = [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]+urlpatterns
Adam Cameron
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Adam Cameron
Python Web Development Techdegree Graduate 16,731 Points

So my issue was that the toolbar would show up, but only when I added the Workspaces-specific language (I'm on my local environment). I thought that was weird but it seems the link to the debug toolbar docs links to an older version and I just wasn't noticing that. So my problems were stemming from that. Thank you!