You can create your own so called "middleware", which is a system in Django for hooking into the request/response processing.
By defining a "process_exception" method, you can catch any exception that a view raises, and do with it what you like.
Here's an example (<YOUR-APP>/middleware.py):
import sys
import traceback
class HandleExceptionsMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
return response
def process_exception(self, request, exception):
print("Internal Server Error: " + request.get_full_path(), file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
Then, in settings.py, you can add your middleware:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
...
'<YOUR-APP>.middleware.HandleExceptionsMiddleware',
]
In this case, we're simply writing to stderr which will make it visible in GAE.