Login

Super User Conditional Page Exception Reporting

Author:
zbyte64
Posted:
July 31, 2008
Language:
Python
Version:
.96
Score:
27 (after 27 ratings)

Step 1 Save somewhere in your project directory

Step 2 Add to your settings.py

MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.middleware.doc.XViewMiddleware',
  'utils.debug.UserBasedExceptionMiddleware',
)

Normal users will get your 500.html when debug = False, but If you are logged in as a super user then you get to see the stack trace in all its glory.

1
2
3
4
5
6
7
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())

More like this

  1. A wrapper around cache_page making it optional by rixx 2 days, 6 hours ago
  2. Treat empty value on DateRangeFilter as a filter for non filled dates by kmmbvnr 1 month, 1 week ago
  3. Django Settings Assignment Expressions aka Walrus Operator example by webology 2 months, 1 week ago
  4. codigo alto nivel by MrRocklion 4 months, 1 week ago
  5. Load template from specific app by Krzysiek555 4 months, 4 weeks ago

Comments

Please login first before commenting.