How to display icon in horizon table

asked 2014-03-20 03:54:55 -0600

DaveJ gravatar image


I have a horizon table (tables.DataTable) with two columns. I would like to add a third that displays an icon, but can't find any way to do this.


# Return the image to be used for thw row item
def get_image_url(item):
    return "<a href=\"/test\"><IMG SRC=\"image.gif\" ALT=\"some text\" WIDTH=32 HEIGHT=32></a>"

class StackCatalogueTable(tables.DataTable):
    # This coloumn should display the icon
    image = tables.Column(get_image_url, verbose_name=_(""))
    name = tables.Column("name", verbose_name=_("Name"))
    short_description = tables.Column("description", verbose_name=_("Description"))

    class Meta:
        name = "stackcatalogue"
        verbose_name = _("Stack Catalogue")
        row_actions = (LaunchStack,)

In the above, I've tried to embed the tag into the table, but it just displays the html text, as opposed to the image.

When I view the source code, I can see that the '<' tags have been converted/escaped to '&lt' and '&gt'

Is there any way to prevent the code from being escaped, or is there a better way to display an Icon?

edit retag flag offensive close merge delete