Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Django Debug Toolbar if it's installed.

  • Loading branch information...
commit 981fe4b779fc597d339d7fe9b3f58ec66c2bc171 1 parent 6be1e52
@jacobian jacobian authored
Showing with 28 additions and 9 deletions.
  1. +7 −3 django_website/settings/docs.py
  2. +21 −6 django_website/settings/www.py
View
10 django_website/settings/docs.py
@@ -2,13 +2,17 @@
PREPEND_WWW = False
APPEND_SLASH = True
+TEMPLATE_CONTEXT_PROCESSORS += ["django.core.context_processors.request"]
+ROOT_URLCONF = 'django_website.urls.docs'
+CACHE_MIDDLEWARE_KEY_PREFIX = 'djangodocs'
+
+_has_ddt = 'debug_toolbar' in INSTALLED_APPS
INSTALLED_APPS = [
'django_website.docs',
'haystack',
]
-TEMPLATE_CONTEXT_PROCESSORS += ["django.core.context_processors.request"]
-ROOT_URLCONF = 'django_website.urls.docs'
-CACHE_MIDDLEWARE_KEY_PREFIX = 'djangodocs'
+if _has_ddt:
+ INSTALLED_APPS.append('debug_toolbar')
# Where to store the build Sphinx docs.
if PRODUCTION:
View
27 django_website/settings/www.py
@@ -45,7 +45,7 @@
SITE_ID = 1
ROOT_URLCONF = 'django_website.urls.www'
-INSTALLED_APPS = (
+INSTALLED_APPS = [
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.admin',
@@ -61,22 +61,24 @@
'django_website.docs',
'registration',
'south',
-)
+]
CACHE_MIDDLEWARE_SECONDS = 60 * 5 # 5 minutes
CACHE_MIDDLEWARE_KEY_PREFIX = 'djangoproject'
CACHE_MIDDLEWARE_GZIP = True
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
-MIDDLEWARE_CLASSES = (
- 'django.middleware.cache.UpdateCacheMiddleware',
+MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
- 'django.middleware.cache.FetchFromCacheMiddleware',
-)
+]
+if PRODUCTION:
+ MIDDLEWARE_CLASSES.insert(0, 'django.middleware.cache.UpdateCacheMiddleware')
+ MIDDLEWARE_CLASSES.append('django.middleware.cache.FetchFromCacheMiddleware')
+
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
@@ -103,3 +105,16 @@
# XXX What's this for?
DJANGO_SVN_ROOT = "http://code.djangoproject.com/svn/django/"
+
+# If django-debug-toolbar is installed enable it.
+if not PRODUCTION:
+ try:
+ import debug_toolbar
+ except ImportError:
+ pass
+ else:
+ # Insert DDT after the common middleware
+ common_index = MIDDLEWARE_CLASSES.index('django.middleware.common.CommonMiddleware')
+ MIDDLEWARE_CLASSES.insert(common_index+1, 'debug_toolbar.middleware.DebugToolbarMiddleware')
+ INTERNAL_IPS = ['127.0.0.1']
+ INSTALLED_APPS.append('debug_toolbar')
Please sign in to comment.
Something went wrong with that request. Please try again.