Search code examples
pythondjangodjango-tables2

Attrs argument doesn't work in URLColumn (Django-tables2)


I'm trying to create a column which points to related user. I've decided to try URLColumn. Text attribute works correctly but when I try to add href url, it renders <a href="None">Text</a>.

Do you know where is the problem?

class PossiblePairsTable(tables.Table):
    customer_one = tables.URLColumn(attrs={'href':'somehref'},text=lambda x: x.reservation_one.customer.userprofile.display_name,)

Solution

  • The URLColumn is meant to be used when the value of the column is a URL.

    Try using the LinkColumn instead.