From e4d652ac6bf9a593e9458640ac46da9f59419602 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 12 Apr 2020 14:52:22 +0100 Subject: [PATCH] Install debug toolbar --- requirements.txt | 1 + website/settings.py | 30 ++++++++++++++++++++++++++---- website/urls.py | 7 ++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7073226..039a19a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ django==3.0.5 +django-debug-toolbar==2.2 diff --git a/website/settings.py b/website/settings.py index c68f350..9a77534 100644 --- a/website/settings.py +++ b/website/settings.py @@ -25,20 +25,19 @@ SECRET_KEY = "gd(%^4!762m4y*c56t(ppm&-5+*a*6-&5)n%nc^aqfi%54^u_j" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = "*" # Application definition -INSTALLED_APPS = [ - "django.contrib.staticfiles", -] +INSTALLED_APPS = ["django.contrib.staticfiles", "debug_toolbar"] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", + "debug_toolbar.middleware.DebugToolbarMiddleware", ] ROOT_URLCONF = "website.urls" @@ -73,3 +72,26 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = "/static/" + + +INTERNAL_IPS = [ + "127.0.0.1", + "localhost", +] + +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.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.panels.profiling.ProfilingPanel", +] + +DEBUG_TOOLBAR_CONFIG = {"SHOW_COLLAPSED": True} diff --git a/website/urls.py b/website/urls.py index e39cb2c..8f32c2e 100644 --- a/website/urls.py +++ b/website/urls.py @@ -1,3 +1,8 @@ -from django.urls import path +import debug_toolbar +from django.conf import settings +from django.urls import include, path urlpatterns = [] + +if settings.DEBUG: + urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))