— wordpress_id: 502 layout: post title: Debugging Django Errors wordpress_url: http://www.davidcramer.net/?p=502 categories: [“django”]—
Today (for many hours) I sat here attempting to debug an error which Django wasn’t spitting out. This happened when combining Django+mod_wsgi and having a runtime import error. The result is a generic white internal server error page from Apache, and nothing recorded in any kind of error log.
So, to make your life easier, I thought I’d help you out by showing what I discovered.
First things first, you’re going to want to install a piece of debugging wsgi middleware. This was new to me, but its basically just a decorating class for your wsgi application. What I used was Paste’s ErrorMiddleware:
pip install -e svn+http://svn.pythonpaste.org/Paste/trunk
Now, pop open your handler file (handler.wsgi in our case). What we did, was make it so if DEBUG is set to True, then it wraps the application handler with the new middleware:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Hope this helps you as much as it helped me!