Skip to content

Commit

Permalink
Use Django Debug Toolbar if it's installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobian committed Feb 1, 2011
1 parent 6be1e52 commit 981fe4b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
10 changes: 7 additions & 3 deletions django_website/settings/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 21 additions & 6 deletions django_website/settings/www.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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')

0 comments on commit 981fe4b

Please sign in to comment.