From 2516b48c88cf1e9373ca1b1a9f629e025557df29 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 8 Dec 2013 14:42:58 +0100 Subject: [PATCH] django-debug-toolbar - we pull it via requirements, so i added the necessary settings so it can work maybe the more simple "quick setup" (see ddt docs) would also have worked, if I had found out earlier that INTERNAL_IPS is a required setting. --- nsupdate/settings.py | 10 ++++++++++ nsupdate/urls.py | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nsupdate/settings.py b/nsupdate/settings.py index 4ddbbb8..7888682 100644 --- a/nsupdate/settings.py +++ b/nsupdate/settings.py @@ -131,6 +131,11 @@ MIDDLEWARE_CLASSES = ( # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) +if DEBUG: + MIDDLEWARE_CLASSES = ( + 'debug_toolbar.middleware.DebugToolbarMiddleware', + ) + MIDDLEWARE_CLASSES + INTERNAL_IPS = ['127.0.0.1', '::1', ] # needed for DebugToolbar! TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + ( 'django.core.context_processors.request', @@ -170,6 +175,11 @@ INSTALLED_APPS = ( 'registration', 'django_extensions', ) +if DEBUG: + DEBUG_TOOLBAR_PATCH_SETTINGS = False + INSTALLED_APPS += ( + 'debug_toolbar', + ) # A sample logging configuration. # Sends an email to the site admins on every HTTP 500 error when DEBUG=False. diff --git a/nsupdate/urls.py b/nsupdate/urls.py index 9358aed..975a14c 100644 --- a/nsupdate/urls.py +++ b/nsupdate/urls.py @@ -67,8 +67,10 @@ urlpatterns = patterns( url(r'^', include('nsupdate.main.urls')), ) -from django.conf import settings - if settings.DEBUG: urlpatterns += patterns('django.contrib.staticfiles.views', url(r'^static/(?P.*)$', 'serve'), ) + import debug_toolbar + urlpatterns += patterns('', + url(r'^__debug__/', include(debug_toolbar.urls)), + )