[Answered ]-How can I add a extra column with django table2?

1πŸ‘

I found a way myself (not sure at all if it’s the best solution or not) :

tables:

class UserListTable(tables.Table):

    delete = tables.LinkColumn(
          'account_delete', 
          args= [A('pk')], 
          attrs= {
            'a': {'class': 'btn'}
          },
          text = 'Delete',

    )
       
    class Meta:
        model = User
        exclude = ("password", "is_superuser", "is_staff", "is_active", "last_login", "date_joined")
        attrs = {
            'class': 'paleblue',
            'th': {
              'class': 'TEST',
            },
        }

url :

    path('account/delete/<int:pk>/', views.account_delete, name='account_delete')  
πŸ‘€jeyremd

Leave a comment