|
29 | 29 | # Set casting and default values |
30 | 30 | DD_SITE_URL=(str, "http://localhost:8080"), |
31 | 31 | DD_DEBUG=(bool, False), |
| 32 | + DD_DJANGO_DEBUG_TOOLBAR_ENABLED=(bool, False), |
32 | 33 | DD_TEMPLATE_DEBUG=(bool, False), |
33 | 34 | DD_LOG_LEVEL=(str, ""), |
34 | 35 | DD_DJANGO_METRICS_ENABLED=(bool, False), |
@@ -356,6 +357,7 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param |
356 | 357 |
|
357 | 358 | # False if not in os.environ |
358 | 359 | DEBUG = env("DD_DEBUG") |
| 360 | +DJANGO_DEBUG_TOOLBAR_ENABLED = env("DD_DJANGO_DEBUG_TOOLBAR_ENABLED") |
359 | 361 | TEMPLATE_DEBUG = env("DD_TEMPLATE_DEBUG") |
360 | 362 |
|
361 | 363 | # Hosts/domain names that are valid for this site; required if DEBUG is False |
@@ -1942,3 +1944,45 @@ def saml2_attrib_map_format(din): |
1942 | 1944 | warnings.filterwarnings("ignore", "The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated.") |
1943 | 1945 | FORMS_URLFIELD_ASSUME_HTTPS = True |
1944 | 1946 | # Inspired by https://adamj.eu/tech/2023/12/07/django-fix-urlfield-assume-scheme-warnings/ |
| 1947 | + |
| 1948 | +if DEBUG: |
| 1949 | + # adding DEBUG logging for all of Django. |
| 1950 | + LOGGING["loggers"]["root"] = { |
| 1951 | + "handlers": ["console"], |
| 1952 | + "level": "DEBUG", |
| 1953 | + } |
| 1954 | + |
| 1955 | +if DJANGO_DEBUG_TOOLBAR_ENABLED: |
| 1956 | + |
| 1957 | + INSTALLED_APPS += ( |
| 1958 | + "debug_toolbar", |
| 1959 | + ) |
| 1960 | + |
| 1961 | + MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware", *MIDDLEWARE] |
| 1962 | + |
| 1963 | + def show_toolbar(request): |
| 1964 | + return True |
| 1965 | + |
| 1966 | + DEBUG_TOOLBAR_CONFIG = { |
| 1967 | + "SHOW_TOOLBAR_CALLBACK": show_toolbar, |
| 1968 | + "INTERCEPT_REDIRECTS": False, |
| 1969 | + "SHOW_COLLAPSED": True, |
| 1970 | + } |
| 1971 | + |
| 1972 | + DEBUG_TOOLBAR_PANELS = [ |
| 1973 | + # 'ddt_request_history.panels.request_history.RequestHistoryPanel', # Here it is |
| 1974 | + "debug_toolbar.panels.versions.VersionsPanel", |
| 1975 | + "debug_toolbar.panels.timer.TimerPanel", |
| 1976 | + "debug_toolbar.panels.settings.SettingsPanel", |
| 1977 | + "debug_toolbar.panels.headers.HeadersPanel", |
| 1978 | + "debug_toolbar.panels.request.RequestPanel", |
| 1979 | + "debug_toolbar.panels.sql.SQLPanel", |
| 1980 | + "debug_toolbar.panels.templates.TemplatesPanel", |
| 1981 | + # 'debug_toolbar.panels.staticfiles.StaticFilesPanel', |
| 1982 | + "debug_toolbar.panels.cache.CachePanel", |
| 1983 | + "debug_toolbar.panels.signals.SignalsPanel", |
| 1984 | + # 'debug_toolbar.panels.logging.LoggingPanel', |
| 1985 | + "debug_toolbar.panels.redirects.RedirectsPanel", |
| 1986 | + "debug_toolbar.panels.profiling.ProfilingPanel", |
| 1987 | + # 'cachalot.panels.CachalotPanel', |
| 1988 | + ] |
0 commit comments