def get_result_and_row_class(cl, field_name, result):
    if django.VERSION >= (1, 9):
        empty_value_display = cl.model_admin.get_empty_value_display()
    else:
        from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
        empty_value_display = EMPTY_CHANGELIST_VALUE
    row_classes = ['field-%s' % field_name]
    try:
        f, attr, value = lookup_field(field_name, result, cl.model_admin)
    except __HOLE__:
        result_repr = empty_value_display
    else:
        if django.VERSION >= (1, 9):
            empty_value_display = getattr(
                attr, 'empty_value_display', empty_value_display)
        if f is None:
            if field_name == 'action_checkbox':
                row_classes = ['action-checkbox']
            allow_tags = getattr(attr, 'allow_tags', False)
            boolean = getattr(attr, 'boolean', False)
            if django.VERSION >= (1, 9):
                result_repr = display_for_value(
                    value, empty_value_display, boolean)
            else:
                result_repr = display_for_value(value, boolean)
            # Strip HTML tags in the resulting text, except if the
            # function has an "allow_tags" attribute set to True.
            # WARNING: this will be deprecated in Django 2.0
            if allow_tags:
                result_repr = mark_safe(result_repr)
            if isinstance(value, (datetime.date, datetime.time)):
                row_classes.append('nowrap')
        else:
            if isinstance(f.rel, models.ManyToOneRel):
                field_val = getattr(result, f.name)
                if field_val is None:
                    result_repr = empty_value_display
                else:
                    result_repr = field_val
            else:
                if django.VERSION >= (1, 9):
                    result_repr = display_for_field(
                        value, f, empty_value_display)
                else:
                    result_repr = display_for_field(value, f)
            if isinstance(f, (models.DateField, models.TimeField,
                              models.ForeignKey)):
                row_classes.append('nowrap')
        if force_str(result_repr) == '':
            result_repr = mark_safe('&nbsp;')
        row_class = mark_safe(' class="%s"' % ' '.join(row_classes))
    return result_repr, row_class
dataset/ETHPy150Open tabo/django-treebeard/treebeard/templatetags/admin_tree.py/get_result_and_row_class