def get_role_ids(course_id):
 roles = Role.objects.filter(course_id=course_id).exclude(name=FORUM_ROLE_STUDENT)
 return dict([(role.name, list(role.users.values_list('id', flat=True))) for role in roles])

def get_role_ids ( course_id ) : roles = Role . objects . filter ( course_id = course_id ) . exclude ( name = FORUM_ROLE_STUDENT ) return dict ( [ ( role . name , list ( role . users . values_list ( 'id' , flat = True ) ) ) for role in roles ] )
returns a dictionary having role names as keys and a list of users as values .