Help us understand the problem. What is going on with this article?

django-debug-toolbar の導入手順メモ

More than 1 year has passed since last update.

前置き

初心者のメモです。
自分の環境ではググった通りにやっても
うごかなかったのでどうにか動いた時のメモです。

django 1.11

ドキュメント
https://django-debug-toolbar.readthedocs.io/en/stable/

pipでインストール

$ pip install django-debug-toolbar

settings.pyに設定を書く

以下リンクよりコピペしました。。。
http://stackoverflow.com/questions/6390310/how-do-i-see-the-django-debug-toolbar

settings.py
if DEBUG:
    INTERNAL_IPS = ('127.0.0.1',)
    MIDDLEWARE += (
        '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,
    }

urls.pyに追加する

your_appのところは適時書き換えてください。

urls.py
from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^your_app/', include('your_app.urls')),
]

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

注意点

デフォルトではbodyタグを検索して直前に挿入される。
なのでbodyタグがないと表示してくれません。

最後に

正直debug-toolbarを見ても?なが多い初心者ですが、動いたことがうれしかったです。
設定等、わからないことが多いので少しずつ勉強したいです。

yowayowa
ぷろぐらまーを目指すおじさん
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした