0

I got confused by the official doc of django-debug-toolbar, http://django-debug-toolbar.readthedocs.org/en/1.3.2/installation.html

According to the Explicit setup, I did below steps:

  • pip install django-debug-toolbar
  • set static folder as Django debug page layout is broken
  • add debug_toolbar to INSTALLED_APPS
  • DEBUG is True in settings.py
  • debug_toolbar.middleware.DebugToolbarMiddleware added in settings.py
  • DEBUG_TOOLBAR_PATCH_SETTINGS = False added in settings.py
  • INTERNAL_IPS = ('127.0.0.1', 'xxx.xx.xxx',) added in settings.py
  • if settings.DEBUG: ... added in urls.py as official doc
  • My json data is showing in Django REST framework template, so I think there is no </body> issue for this problem.

And the toolbar didn't show up, then I found below notes from the official doc

The automatic setup relies on debug_toolbar.models being imported when the server starts. Django doesn’t provide a better hook to execute code during the start-up sequence. This works with manage.py runserver because it validates models before serving requests.

I didn't import debug_toolbar.models in above steps, do I need to do it? and where?

Community
  • 1
  • 1
Yuwen Yan
  • 4,777
  • 10
  • 33
  • 63

1 Answers1

0

No, i don't think you need to import debug_toolbar.models.

  • Check if DEBUG is set to True. The debug toolbar won't be visible if it is set to False.
  • Check if INTERNAL_IPS is set in your settings. The Debug Toolbar is shown only if your IP is listed in the INTERNAL_IPS setting. If browsing locally, add INTERNAL_IPS = ('127.0.0.1',) otherwise add your IPs to the tuple.
  • Check if you have added the debug toolbar middleware class in the MIDDLEWARE_CLASSES settings. Add 'debug_toolbar.middleware.DebugToolbarMiddleware' class to your settings. Include the Debug Toolbar middleware as early as possible in the list. However, it must come after any other middleware that encodes the response’s content, such as GZipMiddleware.
  • Check if your template file is of type text/html and has a closing </body> and </html> tag.
Rahul Gupta
  • 46,769
  • 10
  • 112
  • 126