Django

How To Install Django Debug Toolbar

The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.

For the installation of the Django Debug Toolbar you need to have a django project where you can use pip in a Virtual Environment or without them. If you wan’t use pip, you can get the code of this component from here (https://github.com/jazzband/django-debug-toolbar) and put it in your django project path. But is more easy the pip installation and we will focus on this.

For installation we recommend use the virtual env and execute this command:

pip install django-debug-toolbar

The configuration of this component is simple, but because most of the configuration must be done in the core of the settings of the project, we recommend to do it independently.

First, in your general project urls.py, enter this code:

from django.conf import settings
from django.conf.urls import include, url

if settings.DEBUG:
   import debug_toolbar
   urlpatterns += [
       url(r'^__debug__/', include(debug_toolbar.urls)),
   ]

Take care with the “imports” because it’s possible that you duplicate some of this.

In the settings.py we enter our independent conf for this component, like this:

DEBUG = True

if DEBUG:
   INTERNAL_IPS = ('127.0.0.1', 'localhost',)
   MIDDLEWARE_CLASSES += (
       'debug_toolbar.middleware.DebugToolbarMiddleware',
   )

   INSTALLED_APPS += (
       'debug_toolbar',
   )

   DEBUG_TOOLBAR_PANELS = [
       'debug_toolbar.panels.versions.VersionsPanel',
       'debug_toolbar.panels.timer.TimerPanel',
       'debug_toolbar.panels.settings.SettingsPanel',
       'debug_toolbar.panels.headers.HeadersPanel',
       'debug_toolbar.panels.request.RequestPanel',
       'debug_toolbar.panels.sql.SQLPanel',
       'debug_toolbar.panels.staticfiles.StaticFilesPanel',
       'debug_toolbar.panels.templates.TemplatesPanel',
       'debug_toolbar.panels.cache.CachePanel',
       'debug_toolbar.panels.signals.SignalsPanel',
       'debug_toolbar.panels.logging.LoggingPanel',
       'debug_toolbar.panels.redirects.RedirectsPanel',
   ]

   DEBUG_TOOLBAR_CONFIG = {
       'INTERCEPT_REDIRECTS': False,
   }

The INTERNAL_IPS conf is valid for a local development environment, if your dev env is different, you just change this field with your valid conf.

This is the default conf and if you want see more options you can see this page:

https://django-debug-toolbar.readthedocs.io/en/stable/configuration.html

Note: Is very important that you have the close body tag ( </body> ) in your base template for the Django Debug Toolbar is showing.

This component has a variety of panels that can be added through the configuration, these panels show different information related to http requests / responses and other relevant debug data, in this url you can see all differents default panels and you can learn how to use and configure it. http://django-debug-toolbar.readthedocs.io/en/stable/panels.html

The result will be a toolbar in your screen right place with debug information like this:

 

And here's a screenshot of the toolbar in action:


About the author

None

How To Use Django-SU
03.20.2017

How To Use Django-SU

One of the many tedious processes that checking permissions has, is that of using the logout and login functionalities to ...

How To Use Coverage in Django
03.13.2017

How To Use Coverage in Django

When you are developing a large project it is usually to forget some parts of the code you want to tests. Coverage.py is a ...

Fast Application Development with Django Starters
03.07.2017

Fast Application Development with Django Starters

If you have been working in the software industry for many years you will probably know that one of the principles in ...

How To Install Django-LocalFlavor
03.03.2017

How To Install Django-LocalFlavor

Have you ever had to develop a web application with unique fields depending on the country to which the user is focused or ...

Reasons Why Your Business Should Develop a Mobile Application
03.01.2017

Reasons Why Your Business Should Develop a Mobile Application

Look around. How many technological devices do you have near you? Desktop computers, laptops, tablets and obviously ... ...

Why you should use Django for your next website project?
02.14.2017

Why you should use Django for your next website project?

When embarking upon the development of a new web application, one of the most important questions we must ask ourselves is ...

Let’s have a coffee and talk about your project

START A PROJECT

Let’s have a coffee and talk about your project

START A PROJECT

We use cookies to ensure you get the best experience on our website. More info.

Accept