Skip to content

Instantly share code, notes, and snippets.

@jacobpledger
Created October 26, 2017 21:08
Show Gist options
  • Save jacobpledger/656a4c112ef5890d2de347903bdf00ab to your computer and use it in GitHub Desktop.
Save jacobpledger/656a4c112ef5890d2de347903bdf00ab to your computer and use it in GitHub Desktop.
Django Middleware to Allow Debug for Superusers
# copy this into your project and add the class to
# your MIDDLEWARE_CLASSES in your settings
from django.views.debug import technical_500_response
import sys
class UserBasedExceptionMiddleware(object):
def process_exception(self, request, exception):
if request.user.is_superuser:
return technical_500_response(request, *sys.exc_info())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment