Created
September 3, 2012 06:34
-
-
Save svetlyak40wt/3607315 to your computer and use it in GitHub Desktop.
Django trace for superuser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # source: http://blog.lalf.ru/2012/01/django-traceback-production.html#more | |
| 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()) | |
| # И в settings.py к настройке MIDDLEWARE_CLASSES допишем следующее: | |
| # 'core.debug.UserBasedExceptionMiddleware', | |
| # Чтобы получилось что-то такое: | |
| MIDDLEWARE_CLASSES = ( | |
| 'django.middleware.common.CommonMiddleware', | |
| 'django.contrib.sessions.middleware.SessionMiddleware', | |
| 'django.middleware.csrf.CsrfViewMiddleware', | |
| 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
| 'django.contrib.messages.middleware.MessageMiddleware', | |
| 'core.debug.UserBasedExceptionMiddleware', | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment