@never_cache
def handle500(request):    
    # Let's attempt to render a more useful error message
    errorid, ctx, exception = get_exception_info(request)
    
    # We log the raw error to the log file, so that splunk can pick it up as
    # JSON.
    error_logger.error(json.dumps(exception, sort_keys=True))
    
    # Build up the URL for making the query
    lang_code = request.LANGUAGE_CODE
    query_args = {
        "q": 'search index=_internal sourcetype=django_error "%s" | head 1 | spath' % errorid,
        "display.events.maxlines": 0,
        "display.general.type": "events",
        "earliest": 0,
        "latest": ""
    }
    query_string = urllib.urlencode(query_args)
    ctx['search_url'] = make_splunkweb_url("/%s/app/search/search?%s" % (lang_code, query_string))
    
    return HttpResponseServerError(render_to_string('splunkdj:500.html', context_instance=Context(ctx)))
dataset/ETHPy150Open splunk/splunk-webframework/server/splunkdj/views.py/handle500/original