Review Board and the Django Debug Toolbar

There are a couple of posts on this blog that deal with debugging using the python debugger, pdb (first article and second article). It’s a useful tool, and often beats printing to the console.

While setting breakpoints with pdb is nice if you have an idea where your code might be failing, it can be a bit tedious to use as a first-pass debugging tool. What if a page is loading funny, but no exceptions are raised? Perhaps all you did wrong was misspell a template variable or GET parameter? In this case, it would be nice to be able to quickly look at what your application was doing, from the request to response.

The django-debug-toolbar fills this role nicely. It provides quick and easy access to various, helpful debug information, right from the browser. When the toolbar is installed, a nicely styled, configurable, and collapsable console is displayed off to the side of the page you’re viewing. It offers up information like:

  • HTTP headers
  • Request variables
  • the SQL that was executed when bringing you the current page (also shows the number of queries and time spent on each, great for finding views that overuse the DB)
  • the templates (and the context variables!) that were loaded for the current page
  • Any signals that were sent and their receivers (if any)
  • Logging output and any django.contrib.messages

In addition, installing the toolbar adds the debugsqlshell command, a tool that displays the SQL generated by the Django ORM.

Getting the toolbar running is simple. First, install the toolbar in your Review Board virtualenv (if you’re not using virtualenv, here are some instructions on how to get it up and running):

$ pip install django-debug-toolbar
# or
$ easy_install django-debug-toolbar

Next, open up (the place for your custom Review Board application settings. It should be in the project root directory—if it’s not you might need to run ./contrib/internal/ from the project root to have it created for you). Add the following lines:


RB_EXTRA_APPS += ['debug_toolbar', 'django_extensions']

# Intercepting redirects inserts an intermediate page between a redirect,
# so you can inspect the request and/or response. It's usually not
# necessary, so keep it out of the way by overriding the default
# configuration.

Finally, fire up the dev server and the toolbar should be there. Have a look at some of the third-party panels for some more specialized debug information that might be useful.


One thought on “Review Board and the Django Debug Toolbar

  1. Pingback: Getting up to speed with Review Board | Review Board Student Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s