Closed
Description
I detailed my experiments with this here: https://stackoverflow.com/questions/54346767/django-2-0-custom-middleware-process-exception-hook-not-firing?noredirect=1#comment95511527_54346767
Basically I have a custom middleware class that has a process_exception
method, but if I also have debug toolbar enabled with the profiling panel added in DEBUG_TOOLBAR_PANELS
than the process_exception
method in my middleware class will never fire, I can see the traceback for the error occuring but the returned response is a standard django 500 debug page.
Middleware:
class MyMiddleware(MiddlewareMixin):
def process_exception(self, request, exception):
print("Exception!")
Activated middleware
DJANGO_MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'path.to.MyMiddleware',
]
Panels:
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
'debug_toolbar.panels.profiling.ProfilingPanel', # commenting this out works
)
Metadata
Metadata
Assignees
Labels
No labels