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
Ok guys, I think this an important thing to note, as it's year 2016 and many people are using Django Rest Framework instead of standard django forms, I've wasted 2 hours on figuring out why my exceptions are being handled by a renderer and it never gets to the middleware, the solution to the problem is simple.
http://www.django-rest-framework.org/api-guide/exceptions/#custom-exception-handling
So like this:
import traceback
from rest_framework.views import exception_handler
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first,
# to get the standard error response.
response = exception_handler(exc, context)
traceback.print_exc()
return response
And then in settings define the exception handler as such:
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'utils.custom_exception_handler.custom_exception_handler'
}