11

I have just installed the Django debug toolbar. It was slightly fiddly and although it is working I wanted to check if this is the correct way. Here are the 4 steps that I need to achieve success:

  1. easy_install django_debug_toolbar
  2. add 'debug_toolbar.middleware.DebugToolbarMiddleware', to the end of my middleware classes in my project settings
  3. edit INTERNAL_IPS = ('127.0.0.1') in my django.global_settings.py
  4. then I added "/usr/local/lib/python2.7/dist-packages/django_debug_toolbar-0.8.5-py2.7.egg/debug_toolbar/templates" to my TEMPLATE_DIRS in project settings.

This was largely trial and error so I'm not sure this is the way to go. I am oarticoluarly unsure if step 4 is necessary...

Any input would be much appreciated

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
Darwin Tech
  • 18,449
  • 38
  • 112
  • 187
  • "it is working" should be answer enough. Subjective "better way" questions and answers are outside the scope of this site. – George Cummins Oct 17 '11 at 16:37
  • 5
    Step 4 should definitely not be required. – Daniel Roseman Oct 17 '11 at 16:38
  • @Daniel Roseman. That's what I thought. Could this be because django_debug_toolbar is not in the python path? How should I rectify this? – Darwin Tech Oct 17 '11 at 16:54
  • the django debug toolbar middleware seems to be on my python path. If I remove the TEMPLATES_DIR setting, in the error output I get: '/usr/local/lib/python2.7/dist-packages/django_debug_toolbar-0.8.5-py2.7.egg' in Python Path. – Darwin Tech Oct 17 '11 at 17:32
  • 2
    oops. the problem seems to have been me not adding 'debug_toolbar', to the INSTALLED_APPS in project settings.py. Thanks for the help - maybe this could help someone else. – Darwin Tech Oct 17 '11 at 17:40
  • FYI: 1) if you easy_install or pip, it *is* on the PYTHONPATH. 2) You have to have `app_directories` as one of your template loaders in settings.py, but other than that all templates will pull fine from third-party apps automatically (assuming of course, they're listed in your INSTALLED_APPS, which was your issue here). – Chris Pratt Oct 17 '11 at 19:09
  • What are your TEMPLATE_LOADERS ? – Issac Kelly Oct 18 '11 at 02:41
  • 2
    While many people think this, I believe that it is wrong. If there is only ONE answer then why can the community vote on the BEST answer? It should just be a boolean flag... solves? true/false -- There are many different ways to solve some problems and the ability to put something out there and letting people give their opinion and let the community vote on it is what makes this site so great. Discussion around good/better/best are very valuable. I wish that more people felt this way here. UPVOTE to Darwin because I was having the same issue with the path, and I think his question is fine. – David S Apr 13 '12 at 20:46

3 Answers3

4

I was having the same problems. But, I think I figured it out. I believe the step you are missing is to add 'debug_toolbar' to your projects setting.py INSTALLED_APPS tuple. This solves it for me. Here is a link to the article that I used as a reference.

David S
  • 12,967
  • 12
  • 55
  • 93
4

The INTERNAL_IPS should be a list or tuple, not a string, so:

INTERNAL_IPS = ('127.0.0.1', )   # note, comma
Michał Šrajer
  • 30,364
  • 7
  • 62
  • 85
0

You have to flow the command Like this:

1.install:
   python -m pip install django-debug-toolbar
2.settings.py
INSTALLED_APPS = [
    .,
    .,
    'debug_toolbar'
]
MIDDLEWARE = [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    .,
    .

    
]
INTERNAL_IPS = [
    '127.0.0.1',

]
3. urls.py
import debug_toolbar
urlpatterns = [
  path('admin/', admin.site.urls),
  path('__debug__/', include('debug_toolbar.urls')),

  ] 

Now you can see the debug_toolbarin when you hit the url.

Shaiful Islam
  • 335
  • 2
  • 12