

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:
            if (field_name == '__str__'):
                header = lookup_opts.verbose_name
            else:
                attr = getattr(cl.model, field_name)
                try:
                    header = attr.short_description
                except AttributeError:
                    header = field_name.replace('_', ' ')
            if (not getattr(getattr(cl.model, field_name), 'admin_order_field', None)):
                (yield {
                    'text': header,
                })
                continue
        else:
            if (isinstance(attr.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/VarMisuse@161/221 `f`->`attr`