I have two classes
- Club with property id and name
- Student with property id, name and clubs (list)
One student can be part of multiple clubs.
One club can have multiple students
class Club:
def __init__(self, id, name):
self.id = id
self.name = name
class Student:
def __init__(self, id, name, clubs):
self.id = id
self.name = name
self.clubs = clubs
I want to have a dictionary where the key is club name and value is list of students.
I have around 30 different many to many relationships in the application.
Is there a way to do it in a generic way?