@register.filter(name='asset_which_groups')
def asset_which_group(asset, member):
 member = getattr(asset, member)
 names = [members.name for members in member.all()]
 return ','.join(names)

@ register . filter ( name = 'asset_which_groups' ) def asset_which_group ( asset , member ) : member = getattr ( asset , member ) names = [ members . name for members in member . all ( ) ] return ',' . join ( names )
instance is a user object .