I'm using the default django models ( User and Group ) and I'm trying to display the user's group in a table rendered with django tables2
.
The table is as follows:
class UserTable(tables.Table):
selection = tables.CheckBoxColumn(accessor="pk",
attrs={"th__input": {"onclick": "toggleall(this)"}}, orderable=False)
username = tables.LinkColumn('edituser', args=[A('pk')])
first_name = tables.Column()
last_name = tables.Column()
group = tables.Column(accessor='user.groups.group_id')
class Meta:
template = 'django_tables2/bootstrap.html'
attrs = {'class': 'table table-bordered table-striped table-hover'}
sequence = ('selection','username', 'first_name', 'last_name', 'group')
Thank for helping
I was able to find a solution:
render_groups return the list of all in which the user is part of