def run_detail(request, run_id):
    test_run = get_object_or_404(TestRun, id=run_id)
    
    sort = request.GET.get('sort')
    
    if sort == 'response_time':
        order_by = '-timer_total'
    elif sort == 'sql_queries':
        order_by = '-sql_num_queries'
    elif sort == 'sql_time':
        order_by = '-sql_time'
    else:
        order_by = '-timestamp'
    
    test_run.set_aggregates()
    
    p = Paginator(test_run.records.order_by(order_by), RECORDS_PER_PAGE)
    try:
        page_num = int(request.GET.get('p', 1))
    except __HOLE__:
        page_num = 1
    page = p.page(page_num)
    
    return render_to_response("debug_logging/run_detail.html", {
        'page': page,
        'test_run': test_run,
        'all_test_runs': _get_all_test_runs(),
    }, context_instance=RequestContext(request))
dataset/ETHPy150Open lincolnloop/django-debug-logging/debug_logging/views.py/run_detail