]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
settings: Use explicit setup for the Debug Toolbar
authorStephen Finucane <stephen.finucane@intel.com>
Wed, 23 Mar 2016 18:24:03 +0000 (18:24 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Thu, 24 Mar 2016 17:34:58 +0000 (17:34 +0000)
The 'django-debug-toolbar' application provides an automatic method of
configuring the plugin. However, as noted in the documentation [1],
this can cause issues like circular imports. In this case, a
"Table 'patchwork.patchwork_state' doesn't exist" exception was being
raised when attempting to do an initial migration.

Resolve this by using the manual configuration provided in the docs.

[1] https://django-debug-toolbar.readthedocs.org/en/1.4/installation.html

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Closes-bug: #29
---
v2: Don't rely on 'settings.DEBUG', as this is set to False in tests

patchwork/settings/dev.py
patchwork/urls.py

index 8c95c335128ec22a33e61d8d8107485f553d7627..8cf052698d887281774983f4d779a27233e44fab 100644 (file)
@@ -18,13 +18,6 @@ from .base import *  # noqa
 # https://docs.djangoproject.com/en/1.6/ref/settings/#core-settings
 #
 
-# Models
-
-if django.VERSION >= (1, 7):
-    INSTALLED_APPS += [
-        'debug_toolbar'
-    ]
-
 # Security
 
 SECRET_KEY = '00000000000000000000000000000000000000000000000000'
@@ -67,6 +60,27 @@ else:
 
 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 
+#
+# Third-party application settings
+#
+
+# django-debug-toolbar
+
+if django.VERSION >= (1, 7):
+    INSTALLED_APPS += [
+        'debug_toolbar'
+    ]
+
+    DEBUG_TOOLBAR_PATCH_SETTINGS = False
+
+    # This should go first in the middleware classes
+    MIDDLEWARE_CLASSES = [
+        'debug_toolbar.middleware.DebugToolbarMiddleware',
+    ] + MIDDLEWARE_CLASSES
+
+    INTERNAL_IPS = ['127.0.0.1', '::1']
+
+
 #
 # Patchwork settings
 #
index 022b92cf86edaf3db8eb101c6df4d3e8eb2f2f02..bf8a123e59a287809bac5f6a3322b088ff45f98a 100644 (file)
@@ -17,6 +17,7 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import django
 from django.conf import settings
 from django.conf.urls import url, include
 from django.contrib import admin
@@ -122,6 +123,12 @@ urlpatterns = [
     url(r'^help/(?P<path>.*)$', help_views.help, name='help'),
 ]
 
+if 'debug_toolbar' in settings.INSTALLED_APPS:
+    import debug_toolbar
+    urlpatterns += [
+        url(r'^__debug__/', include(debug_toolbar.urls)),
+    ]
+
 if settings.ENABLE_XMLRPC:
     urlpatterns += [
         url(r'xmlrpc/$', xmlrpc_views.xmlrpc, name='xmlrpc'),