django Internal server error 500 Modify source code to view print errors

Internal Server Error 500 is an annoying error that will probably make you want to smash your computer.
because this error caused too many sources, (I, often encountered the background py file error, including some very incredible format errors)
so looking for a long time on the Internet finally found a good solution

use python pyamf client connect to the server, only quote us this error:
pyamf.remoting.RemotingError: HTTP Error 500: INTERNAL SERVER ERROR
If you just look at this mistake, you’ll get confused. You have to make the error report more specific.
Think about it, there are two ways to make the error location, one is to change pyAMf source code, one is to change the source code of Django, let Django directly print out 500 error messages.
This is done with the second idea.
Django 500 source: python2.7/site – packages/django/core/handlers/base. Py
The source code is as follows, the middle section is added by me, so that the detailed error can be displayed:
def handle_uncaught_exception(self, request, resolver, Exc_info):
“”
Processing for any otherwise uncaught exceptions (those that will
generate HTTP 500 responses). Can be overridden by subclasses who want
customised 500 handling

    Be *very* careful when overriding this because the error could be
    caused by anything, so assuming something like the database is always
    available would be an error.
    """
    from django.conf import settings

    if settings.DEBUG_PROPAGATE_EXCEPTIONS:
        raise

    logger.error('Internal Server Error: %s', request.path,
        exc_info=exc_info,
        extra={
            'status_code': 500,
            'request': request
        }
    )
    #============= Code start ========== by chang
    print "---------- HTTP 500 Error Msg ---------- "
    print exc_info
    import traceback
    print traceback.format_exc()
    print "---------------------------------------- " 
    #============= Code end =========

    if settings.DEBUG:
        from django.views import debug
        return debug.technical_500_response(request, *exc_info)

    # If Http500 handler is not installed, re-raise last exception
    if resolver.urlconf_module is None:
        raise exc_info[1], None, exc_info[2]
    # Return an HttpResponse that displays a friendly error message.
    callback, param_dict = resolver.resolve500()
    return callback(request, **param_dict)

Read More: