django-tables2 add button per row

前端 未结 1 997
余生分开走
余生分开走 2021-02-19 21:08

I\'m rendering a queryset with django-tables 2 but since the table is rendered at once I can\'t manage the following: Firstly, I should mention that the number of rows of the ta

相关标签:
1条回答
  • 2021-02-19 21:48

    You can create in your table a template column, this will render something, a button for example:

    class MyTables(tables.Table):
      ...
      my_column = tables.TemplateColumn(verbose_name=_('My Column'),
                                        template_name='app/my_column.html',
                                        orderable=False) # orderable not sortable
    

    In the template my_column the row is in the variable record:

    {{ record.my_field }}
    
    0 讨论(0)
提交回复
热议问题