Ticket #2301: list_display_links.th.patch

File list_display_links.th.patch, 1.3 KB (added by kilian <kilian.cavalotti@…>, 18 years ago)

Patch to display non-first link columns as <td>

  • django/contrib/admin/templatetags/admin_list.py

     
    167167            result_repr = '&nbsp;'
    168168        # If list_display_links not defined, add the link tag to the first field
    169169        if (first and not cl.lookup_opts.admin.list_display_links) or field_name in cl.lookup_opts.admin.list_display_links:
     170            table_tag = {True:'th', False:'td'}[first]
    170171            first = False
    171172            url = cl.url_for_result(result)
    172173            result_id = str(getattr(result, pk)) # str() is needed in case of 23L (long ints)
    173             yield ('<th%s><a href="%s"%s>%s</a></th>' % \
    174                 (row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr))
     174            yield ('<%s%s><a href="%s"%s>%s</a></%s>' % \
     175                (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr, table_tag))
    175176        else:
    176177            yield ('<td%s>%s</td>' % (row_class, result_repr))
    177178
Back to Top