In Django Middleware is a class which respond to one of these methods:
process_exception. For more informations see the Django middleware docs.
Quite cool thing I discovered recently is that you can deploy WSGI applications (Django etc) on Passenger. There is an example app for WSGI out there. Similarly as in Ruby, you have
which looks like this (it's a slightly modified version of the linked example):