Werkzeug

wsgi utility collection


Using the Werkzeug Debugger With Django

Django comes with a technical internal server error page that displays all the exception frames. However you don't have the possibility to directly paste to lodgeit and you also cannot execute python expressions in the frames.

Unfortunately django doesn't allow to disable the internal error processing and hook in WSGI middlewares for older Django versions it needs a hack:

#!/usr/bin/env python
from werkzeug import run_simple, DebuggedApplication
from django.core.handlers.wsgi import WSGIHandler

# This is only needed for Django versions < [7537]:
def null_technical_500_response(request, exc_type, exc_value, tb):
    raise exc_type, exc_value, tb
from django.views import debug
debug.technical_500_response = null_technical_500_response

if __name__ == '__main__':
    run_simple('localhost', 8080, DebuggedApplication(WSGIHandler(), True))

Save it as "django-run-debugged.py" and run it. Don't forget to set the DJANGO_SETTINGS_MODULE environment variable!