Created
May 26, 2016 07:10
-
-
Save kellerkind/c40e481daf40dd579d9875dacdfc9c8c to your computer and use it in GitHub Desktop.
django-tables2 MultiLinkColumn Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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