Sep 03

User Based Debug your Django App

Ever wanted to view the verbose Django error page when you're live app is executing with DEBUG=False?

I'm a huge fan of this Erich Holscher djangosnippet which is included in django-sugar. This middleware allows you to easily debug your django app whether you're an admin user or your machine's IP is listed in INTERNAL_IPS tuple. Here is is in its entirety below.

from django.views.debug import technical_500_response
import sys
from django.conf import settings
class UserBasedExceptionMiddleware(object):
    def process_exception(self, request, exception):
        if request.user.is_superuser or request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
            return technical_500_response(request, *sys.exc_info())

Tags: debug, snippet


OSWCO is dedicated to introducing and supporting Open Source Software to the Enterprise. The Open Source movement and products have become highly sophisticated, cost effective, and mature. Many leading companies and organizations are making rapidly increasing investments in it's use.

To see our Information about Google Apps click Google Apps Info

OSWCO is an authorized Google Apps reseller. Some organizations need help and a place to turn to for, consulting, product development or commercial support. We have developed an extensive network of reliable experts to assist you, able to take on the largest turnkey projects. Contact us to help you examine the options. Phone: 205-267-1089. More info:

Subscribe to us:



Recent Posts



Popular Posts

Django Popular