I\'m using urlib to hit my app not a browser so I can\'t see the debug screen when an error occurs. What\'s the best way to send the normal debug info to the console or a fi
I was getting 500 Internal Server Error and was not able to debug it as the code was not accessed through a browser and terminal didn't show the traceback. This bit of code in a middleware made all the difference:
import traceback
import sys
class ProcessExceptionMiddleware(object):
def process_response(self, request, response):
if response.status_code != 200:
print '\n'.join(traceback.format_exception(*sys.exc_info()))
return response
Instead of processing the exception I, am processing the response object and printing the traceback when the status code not 200 and voila I can now see what is causing the error. Which in this particular case was an improperly indented block.
Yuji's answer above and the middleware documentation helped me reach this solution.