Browse Source

disable debug_toolbar by default

Nick Sweeting 4 years ago
parent
commit
d89034dcde
1 changed files with 24 additions and 18 deletions
  1. 24 18
      archivebox/core/settings.py

+ 24 - 18
archivebox/core/settings.py

@@ -40,8 +40,7 @@ LOGOUT_REDIRECT_URL = '/'
 PASSWORD_RESET_URL = '/accounts/password_reset/'
 PASSWORD_RESET_URL = '/accounts/password_reset/'
 APPEND_SLASH = True
 APPEND_SLASH = True
 
 
-DEBUG = True    # DEBUG or ('--debug' in sys.argv)
-DEBUG_TOOLBAR = True
+DEBUG = DEBUG or ('--debug' in sys.argv)
 
 
 INSTALLED_APPS = [
 INSTALLED_APPS = [
     'django.contrib.auth',
     'django.contrib.auth',
@@ -55,6 +54,29 @@ INSTALLED_APPS = [
 
 
     'django_extensions',
     'django_extensions',
 ]
 ]
+
+
+MIDDLEWARE = [
+    'django.middleware.security.SecurityMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+]
+
+AUTHENTICATION_BACKENDS = [
+    'django.contrib.auth.backends.ModelBackend',
+]
+
+DEBUG_TOOLBAR = False
+if DEBUG:
+    try:
+        import debug_toolbar
+        DEBUG_TOOLBAR = True
+    except ImportError:
+        pass
+
 if DEBUG_TOOLBAR:
 if DEBUG_TOOLBAR:
     INSTALLED_APPS = [*INSTALLED_APPS, 'debug_toolbar']
     INSTALLED_APPS = [*INSTALLED_APPS, 'debug_toolbar']
     INTERNAL_IPS = ['0.0.0.0', '127.0.0.1', '*']
     INTERNAL_IPS = ['0.0.0.0', '127.0.0.1', '*']
@@ -79,24 +101,8 @@ if DEBUG_TOOLBAR:
         'debug_toolbar.panels.profiling.ProfilingPanel',
         'debug_toolbar.panels.profiling.ProfilingPanel',
         'djdt_flamegraph.FlamegraphPanel',
         'djdt_flamegraph.FlamegraphPanel',
     ]
     ]
-
-
-MIDDLEWARE = [
-    'django.middleware.security.SecurityMiddleware',
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    'django.middleware.common.CommonMiddleware',
-    'django.middleware.csrf.CsrfViewMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.contrib.messages.middleware.MessageMiddleware',
-]
-if DEBUG_TOOLBAR:
     MIDDLEWARE = [*MIDDLEWARE, 'debug_toolbar.middleware.DebugToolbarMiddleware']
     MIDDLEWARE = [*MIDDLEWARE, 'debug_toolbar.middleware.DebugToolbarMiddleware']
 
 
-AUTHENTICATION_BACKENDS = [
-    'django.contrib.auth.backends.ModelBackend',
-]
-
-
 ################################################################################
 ################################################################################
 ### Staticfile and Template Settings
 ### Staticfile and Template Settings
 ################################################################################
 ################################################################################