@pytest.mark.django_db
def test_td_attrs_should_be_supported():
 person = Person.objects.create(first_name=u'Bob', last_name=u'Builder')
 class Table(tables.Table, ):
  first_name = tables.LinkColumn(attrs={u'a': {u'style': u'color: red;'}, u'td': {u'style': u'background-color: #ddd;'}})
  last_name = tables.Column()
 table = Table(Person.objects.all())
 a_tag = table.rows[0].get_cell(u'first_name')
 assert (u'href="{}"'.format(reverse(u'person', args=(person.pk,))) in a_tag)
 assert (u'style="color: red;"' in a_tag)
 assert (person.first_name in a_tag)
 html = table.as_html(build_request())
 td_tag_1 = u'<td style="background-color: #ddd;" class="first_name">'
 td_tag_2 = u'<td class="first_name" style="background-color: #ddd;">'
 assert ((td_tag_1 in html) or (td_tag_2 in html))

@ pytest . mark . django_db def test_td_attrs_should_be_supported ( ) : person = Person . objects . create ( first_name = u'Bob' , last_name = u'Builder' ) class Table ( tables . Table , ) : first_name = tables . LinkColumn ( attrs = { u'a' : { u'style' : u'color: red;' } , u'td' : { u'style' : u'background-color: #ddd;' } } ) last_name = tables . Column ( ) table = Table ( Person . objects . all ( ) ) a_tag = table . rows [ 0 ] . get_cell ( u'first_name' ) assert ( u'href="{}"' . format ( reverse ( u'person' , args = ( person . pk , ) ) ) in a_tag ) assert ( u'style="color: red;"' in a_tag ) assert ( person . first_name in a_tag ) html = table . as_html ( build_request ( ) ) td_tag_1 = u'<td style="background-color: #ddd;" class="first_name">' td_tag_2 = u'<td class="first_name" style="background-color: #ddd;">' assert ( ( td_tag_1 in html ) or ( td_tag_2 in html ) )
linkcolumn should support both <td> and <a> attrs .