Skip to content

Instantly share code, notes, and snippets.

@yujinyuz
Created November 5, 2020 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yujinyuz/9815da8f1ec1a723718d3091b6ede856 to your computer and use it in GitHub Desktop.
Save yujinyuz/9815da8f1ec1a723718d3091b6ede856 to your computer and use it in GitHub Desktop.
Allow debugging in production for superusers
# core/middleware.py
import sys
from django.views.debug import technical_500_response
class UserBasedExceptionMiddleware:
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