diff --git a/opentech/settings/dev.py b/opentech/settings/dev.py index 873783137117905ee720e1cac3b58f82c0af3732..280e44591cf6e014757cceac0dba79926a97b792 100644 --- a/opentech/settings/dev.py +++ b/opentech/settings/dev.py @@ -8,8 +8,6 @@ SECRET_KEY = 'CHANGEME!!!' WAGTAIL_CACHE = False -INTERNAL_IPS = ('127.0.0.1', '10.0.2.2') - ALLOWED_HOSTS = ['apply.localhost', 'localhost', '127.0.0.1', 'dev.otf.is', 'dev-apply.otf.is'] BASE_URL = 'http://localhost:8000' @@ -106,15 +104,42 @@ if LOCAL_FILE_LOGGING: } } -# Set up the Django debug toolbar. See also root urls.py. -if DEBUGTOOLBAR: - INSTALLED_APPS += [ + +# Debug Toolbar +# https://django-debug-toolbar.readthedocs.io/en/latest/index.html +if DEBUG: + INSTALLED_APPS = [ + *INSTALLED_APPS, 'debug_toolbar', ] - MIDDLEWARE = [ 'debug_toolbar.middleware.DebugToolbarMiddleware', - ] + MIDDLEWARE + *MIDDLEWARE, + ] + # The 10.0.x address here allows vagrant users to use the debug toolbar + # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#configuring-internal-ips + INTERNAL_IPS = ['127.0.0.1', '10.0.2.2'] + +# We disable all panels by default here since some of them (SQL, Template, +# Profiling) can be very CPU intensive for this site. However disabled panels +# can be easily toggled on in the UI. +DEBUG_TOOLBAR_CONFIG = { + "DISABLE_PANELS": { + 'debug_toolbar.panels.versions.VersionsPanel', + '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.panels.profiling.ProfilingPanel', + }, + "SHOW_COLLAPSED": True, +} WEBPACK_LOADER['DEFAULT'].update({ diff --git a/opentech/settings/local.py.example b/opentech/settings/local.py.example index 92f433c824e09f4227d49a046a04bc066046165d..571bc3a535e6f03f4c622d7118dd7f5c12b17afb 100644 --- a/opentech/settings/local.py.example +++ b/opentech/settings/local.py.example @@ -7,10 +7,6 @@ CACHES = { } } -# Use the Django debug toolbar. First install via pip. -# pip install django-debug-toolbar -# DEBUGTOOLBAR = True - # Write log to local file. # LOCAL_FILE_LOGGING = True diff --git a/opentech/urls.py b/opentech/urls.py index 2aa4a198c885865d2e0d283fcb36893c4410586c..e94c4103b286ac371e8257e5f34479df0ba524f2 100644 --- a/opentech/urls.py +++ b/opentech/urls.py @@ -65,7 +65,7 @@ urlpatterns += [ ] -if settings.DEBUG and settings.DEBUGTOOLBAR: +if settings.DEBUG: import debug_toolbar urlpatterns = [ path('__debug__/', include(debug_toolbar.urls)), diff --git a/requirements-dev.txt b/requirements-dev.txt index fd0aaa57b41f9cb5399cc97a4c4520274245e55a..b6293527765f4036b86ab4359c4b8c9a4a76528c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ -r requirements.txt +django-debug-toolbar==2.0 factory_boy==2.9.2 Faker==1.0.8 # Pinning to avoid API changes to pydecimal in 0.x - could go higher in future flake8==3.7.9