I looked at other questions and can't figure it out...
I did the following to install django-debug-toolbar:
- pip install django-debug-toolbar
- added to middleware classes:
MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', )
3 Added INTERNAL_IPS:
INTERNAL_IPS = ('174.121.34.187',)
4 Added debug_toolbar to installed apps
I am not getting any errors or anything, and the toolbar doesn't show up on any page, not even admin.
I even added the directory of the debug_toolbar templates to my TEMPLATE_DIRS
The current stable version 0.11.0 requires the following things to be true for the toolbar to be shown:
Settings file:
DEBUG = True
INTERNAL_IPS
to include your browser IP address, as opposed to the server address. If browsing locally this should beINTERNAL_IPS = ('127.0.0.1',)
. If browsing remotely just specify your public address.INSTALLED_APPS = (..., 'debug_toolbar',)
MIDDLEWARE_CLASSES = ('debug_toolbar.middleware.DebugToolbarMiddleware', ...)
. It should be placed as early as possible in the list.Template files:
text/html
</html>
tagStatic files:
If you are serving static content make sure you collect the css, js and html by doing:
Note on upcoming versions of django-debug-toolbar
Newer, development versions have added defaults for settings points 2, 3 and 4 which makes life a bit simpler, however, as with any development version it has bugs. I found that the latest version from git resulted in an
ImproperlyConfigured
error when running through nginx/uwsgi.Either way, if you want to install the latest version from github run:
You can also clone a specific commit by doing:
Docker
If you're developing with a Django server in a Docker container with docker, the instructions for enabling the toolbar don't work. The reason is related to the fact that the actual address that you would need to add to
INTERNAL_IPS
is going to be something dynamic, like 172.24.0.1. Rather than trying to dynamically set the value ofINTERNAL_IPS
, the straightforward solution is to replace the function that enables the toolbar, in yoursettings.py
, for example:This should also work for other dynamic routing situations, like vagrant.
Here are some more details for the curious. The code in django_debug_tool that determines whether to show the toolbar examines the value of
REMOTE_ADDR
like this:so if you don't actually know the value of
REMOTE_ADDR
due to your dynamic docker routing, the toolbar will not work. You can use the docker network command to see the dynamic IP values, for exampledocker network inspect my_docker_network_name
An addition to previous answers:
if the toolbar doesn't show up, but it loads in the html (check your site html in a browser, scroll down)
the issue can be that debug toolbar static files are not found (you can also see this in your site's access logs then, e.g. 404 errors for /static/debug_toolbar/js/toolbar.js)
It can be fixed the following way then (examples for nginx and apache):
nginx config:
apache config:
Or:
more on collectstatic here: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#collectstatic
Or manualy move debug_toolbar folder of debug_toolbar static files to your set static files folder
you have to make sure there is a closing tag in your templates.
My problem is that there is no regular html tags in my templates, I just display content in plain text. I solved it by inheriting every html file from base.html, which has a tag.
I tried the configuration from pydanny's cookiecutter-django and it worked for me:
I just modified it by adding
'debug_toolbar.apps.DebugToolbarConfig'
instead of'debug_toolbar'
as mentioned in the official django-debug-toolbar docs, as I'm using Django 1.7.One stupid thing got me.. that if you use apache wsgi, remember to touch the .wsgi file to force your code recompile. just waste 20 minutes of my time to debug the stupid error :(