Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kellerkind/c40e481daf40dd579d9875dacdfc9c8c to your computer and use it in GitHub Desktop.
Save kellerkind/c40e481daf40dd579d9875dacdfc9c8c to your computer and use it in GitHub Desktop.
django-tables2 MultiLinkColumn Example
class MultiLinkColumn(Column):
def render(self, value):
s = ""
for m in Machine.objects.all():
s += '<a href="list/{}" />Edit {}</a><br/>'.format(m.id, m.id)
return format_html(s)
class MachineTable(tables.Table):
status = LinkColumn('edit', args=[A('pk')], empty_values=())
name = MultiLinkColumn('Name')
class Meta:
model = Machine
attrs = {"class": "paleblue"}
exclude = ('uuid', 'id')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment