Add support for easily enabling the django debug toolbar

This requires the web server to also configure a static mapping for
/media/django_toolbar/ pointing into the django toolbar directories.
This commit is contained in:
Magnus Hagander
2020-08-07 13:37:05 +02:00
parent 11fdccb3bd
commit f5d99ed262
2 changed files with 19 additions and 0 deletions

View File

@ -162,5 +162,15 @@ FRONTEND_SMTP_RELAY = "magus.postgresql.org" # Where to relay use
OAUTH = {} # OAuth providers and keys
PGDG_ORG_ID = -1 # id of the PGDG organisation entry
# For debug toolbar, can then be fully configured in settings_local.py
DEBUG_TOOLBAR = False
INTERNAL_IPS = [
'127.0.0.1',
]
# Load local settings overrides
from .settings_local import *
if DEBUG and DEBUG_TOOLBAR:
MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
INSTALLED_APPS.append('debug_toolbar')

View File

@ -1,5 +1,7 @@
from django.conf.urls import include, url
from django.urls import path
from django.views.generic import RedirectView
from django.conf import settings
import pgweb.contributors.views
import pgweb.core.views
@ -156,3 +158,10 @@ urlpatterns = [
# Fallback for static pages, must be at the bottom
url(r'^(.*)/$', pgweb.core.views.fallback),
]
if settings.DEBUG_TOOLBAR:
import debug_toolbar
urlpatterns = [
path('__debug__/', include(debug_toolbar.urls)),
] + urlpatterns