Skip to content

Commit

Permalink
Set up debug toolbar explicitly when installed. Closes stephenmcd#1358.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcd committed Jul 22, 2015
1 parent 6adea5b commit f8afd35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion mezzanine/urls.py
Expand Up @@ -7,7 +7,7 @@
from __future__ import unicode_literals
from future.builtins import str

from django.conf.urls import patterns, include
from django.conf.urls import patterns, include, url
from django.http import HttpResponse

from mezzanine.conf import settings
Expand All @@ -22,6 +22,16 @@
(r'^jsi18n/(?P<packages>\S+?)/$', 'javascript_catalog', js_info_dict),
)

if settings.DEBUG:
try:
import debug_toolbar
except ImportError:
pass
else:
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)

# Django's sitemap app.
if "django.contrib.sitemaps" in settings.INSTALLED_APPS:
sitemaps = {"sitemaps": {"all": DisplayableSitemap}}
Expand Down
8 changes: 5 additions & 3 deletions mezzanine/utils/conf.py
Expand Up @@ -131,11 +131,13 @@ def set_dynamic_settings(s):
remove("INSTALLED_APPS", "django_extensions")

if "debug_toolbar" in s["INSTALLED_APPS"]:
# We need to configure debug_toolbar manually otherwise it
# breaks in conjunction with modeltranslation. See the
# "Explicit setup" section in debug_toolbar docs for more info.
s["DEBUG_TOOLBAR_PATCH_SETTINGS"] = False
debug_mw = "debug_toolbar.middleware.DebugToolbarMiddleware"
append("MIDDLEWARE_CLASSES", debug_mw)
# Ensure debug_toolbar is before modeltranslation to avoid
# races for configuration.
move("INSTALLED_APPS", "debug_toolbar", 0)
s.setdefault("INTERNAL_IPS", ("127.0.0.1",))

# If compressor installed, ensure it's configured and make
# Mezzanine's settings available to its offline context,
Expand Down

0 comments on commit f8afd35

Please sign in to comment.