[PATCH 2/2] settings: Use explicit setup for the Debug Toolbar
Stephen Finucane
stephen.finucane at intel.com
Thu Mar 24 05:34:39 AEDT 2016
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 at intel.com>
Closes-bug: #29
---
patchwork/settings/dev.py | 28 +++++++++++++++++++++-------
patchwork/urls.py | 8 ++++++++
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py
index 8c95c33..8cf0526 100644
--- a/patchwork/settings/dev.py
+++ b/patchwork/settings/dev.py
@@ -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'
@@ -68,6 +61,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
#
diff --git a/patchwork/urls.py b/patchwork/urls.py
index 022b92c..1fb1050 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -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
@@ -142,3 +143,10 @@ if settings.COMPAT_REDIR:
bundle_views.mbox_redir,
name='bundle-mbox-redir'),
]
+
+
+if settings.DEBUG and django.VERSION >= (1, 7):
+ import debug_toolbar
+ urlpatterns += [
+ url(r'^__debug__/', include(debug_toolbar.urls)),
+ ]
--
2.0.0
More information about the Patchwork
mailing list