diff --git a/MrDoc/settings.py b/MrDoc/settings.py index ad49be5..98dc0b4 100644 --- a/MrDoc/settings.py +++ b/MrDoc/settings.py @@ -226,3 +226,20 @@ try: CHROMIUM_DRIVER_PATH = CONFIG['selenium']['driver_path'] except: CHROMIUM_DRIVER_PATH = None + +INTERNAL_IPS = ('127.0.0.1', '::1') +# Django Debug Toolbar 工具,站点开启调试的时候启用 +try: + import debug_toolbar.settings # noqa + if DEBUG: + INSTALLED_APPS.append('debug_toolbar.apps.DebugToolbarConfig') + MIDDLEWARE.insert(0, 'debug_toolbar.middleware.DebugToolbarMiddleware') + DEBUG_TOOLBAR_PATCH_SETTINGS = False + DEBUG_TOOLBAR_CONFIG = { + 'JQUERY_URL': '', + 'DISABLE_PANELS': debug_toolbar.settings.PANELS_DEFAULTS, + } + + pass +except ImportError: + pass \ No newline at end of file diff --git a/MrDoc/urls.py b/MrDoc/urls.py index 181ce59..ecd84fa 100644 --- a/MrDoc/urls.py +++ b/MrDoc/urls.py @@ -33,3 +33,10 @@ urlpatterns = [ path('sitemap-
.xml', views.sitemap, {'sitemaps': sitemaps,'template_name':'sitemap/sitemap.xml'}, name='django.contrib.sitemaps.views.sitemap') # 站点地图 ] + +if settings.DEBUG: + try: + import debug_toolbar + urlpatterns.append(path('__debug__/', include(debug_toolbar.urls))) + except ImportError: + pass \ No newline at end of file