def result_headers(cl):
    lookup_opts = cl.lookup_opts

    for i, field_name in enumerate(lookup_opts.admin.list_display):
        try:
            f = lookup_opts.get_field(field_name)
        except models.FieldDoesNotExist:
            # For non-field list_display values, check for the function
            # attribute "short_description". If that doesn't exist, fall
            # back to the method name. And __str__ is a special-case.
            if field_name == '__str__':
                header = lookup_opts.verbose_name
            else:
                attr = getattr(cl.model, field_name) # Let AttributeErrors propagate.
                try:
                    header = attr.short_description
                except AttributeError:
                    header = field_name.replace('_', ' ')

            # It is a non-field, but perhaps one that is sortable
            if not getattr(getattr(cl.model, field_name), "admin_order_field", None):
                yield {"text": header}
                continue

            # So this _is_ a sortable non-field.  Go to the yield
            # after the else clause.
        else:
            if isinstance(f.rel, models.ManyToOneRel) and f.null:
                yield {"text": f.verbose_name}
                continue
            else:
                header = f.verbose_name

        th_classes = []
        new_order_type = 'asc'
        if field_name == cl.order_field:
            th_classes.append('sorted %sending' % cl.order_type.lower())
            new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]

        yield {"text": header,
               "sortable": True,
               "url": cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type}),
               "class_attrib": (th_classes and ' class="%s"' % ' '.join(th_classes) or '')}
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-0.96/django/contrib/admin/templatetags/admin_list.py/result_headers/original