我的settings.py文件看起来像-
import os
# This file contains Django settings for lower environments that use the Django Debug Toolbar.
# Currently those envronments are DEV and QA.
from core.settings import * # noqa: F403
# We need the ability to disable debug_toolbar for regression tests.
DEBUG = os.getenv('DEBUG_MODE', 'FALSE').upper() == 'TRUE'
def toolbar_callback(request):
return DEBUG
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": toolbar_callback,
}
INSTALLED_APPS += ['debug_toolbar', ] # noqa: F405
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ] # noqa: F405
我想从加载调试工具栏排除某些页面。原因是这些页面有很多SQL和调试工具栏加载时间太长,因此页面超时
1条答案
按热度按时间ui7jx7zq1#
SHOW_TOOLBAR_CALLBACK
的值决定了是否应该在页面上使用调试工具栏。因此,您可以通过评估请求路径来排除特定的URL/URL模式。例如,使用生成器表达式: