Re-add Django-Debug-Toolbar for easier debugging, particularly in the admin

This commit is contained in:
Mathieu Pillard 2019-04-16 15:42:42 +02:00
Родитель 6969f1d7ef
Коммит 766ac85e1a
5 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -25,6 +25,9 @@ ipython_genutils==0.2.0 \
decorator==4.4.0 \
--hash=sha256:86156361c50488b84a3f148056ea716ca587df2f0de1d34750d35c21312725de \
--hash=sha256:f069f3a01830ca754ba5258fde2278454a0b5b79e0d7f5c13b3b97e57d4acff6
django-debug-toolbar==1.11 \
--hash=sha256:89d75b60c65db363fb24688d977e5fbf0e73386c67acf562d278402a10fc3736 \
--hash=sha256:c2b0134119a624f4ac9398b44f8e28a01c7686ac350a12a74793f3dd57a9eea0
ptyprocess==0.6.0 \
--hash=sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f \
--hash=sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0

Просмотреть файл

@ -16,8 +16,16 @@ DEBUG = True
# These apps are great during development.
INSTALLED_APPS += (
'olympia.landfill',
'debug_toolbar',
)
MIDDLEWARE = ('debug_toolbar.middleware.DebugToolbarMiddleware',) + MIDDLEWARE
DEBUG_TOOLBAR_CONFIG = {
# Enable django-debug-toolbar locally, if DEBUG is True.
'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG,
}
FILESYSTEM_CACHE_ROOT = os.path.join(TMP_PATH, 'cache')
# We are setting memcached here to make sure our local setup is as close

Просмотреть файл

@ -8,6 +8,10 @@ INSTALLED_APPS += (
)
# Make sure the debug toolbar isn't used during the tests.
INSTALLED_APPS = [app for app in INSTALLED_APPS if app != 'debug_toolbar']
MIDDLEWARE = tuple(
middleware for middleware in MIDDLEWARE
if middleware != 'debug_toolbar.middleware.DebugToolbarMiddleware'
)
# See settings.py for documentation:
IN_TEST_SUITE = True

Просмотреть файл

@ -54,6 +54,11 @@ def path(*folders):
DEBUG = False
DEBUG_TOOLBAR_CONFIG = {
# Deactivate django debug toolbar by default.
'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG,
}
# Ensure that exceptions aren't re-raised.
DEBUG_PROPAGATE_EXCEPTIONS = False
SILENCED_SYSTEM_CHECKS = (
@ -281,6 +286,9 @@ JINJA_EXCLUDE_TEMPLATE_PATHS = (
# Third-party apps using django templates
r'^rangefilter\/',
# Django debug toolbar
r'debug_toolbar',
)
TEMPLATES = [

Просмотреть файл

@ -114,12 +114,14 @@ urlpatterns = [
]
if settings.DEBUG:
import debug_toolbar
# Remove leading and trailing slashes so the regex matches.
media_url = settings.MEDIA_URL.lstrip('/').rstrip('/')
urlpatterns.append(
url(
r'^%s/(?P<path>.*)$' % media_url,
urlpatterns.extend([
url(r'^%s/(?P<path>.*)$' % media_url,
serve_static,
{'document_root': settings.MEDIA_ROOT}),
)
url(r'__debug__/', include(debug_toolbar.urls)),
])