Hello Guys, I am facing some problem to creating the dynamic lists of list by using django models.
subjects = ['M', 'E', 'B', 'C', 'CS', 'G', 'P', 'S', 'H', 'F']
neighbors = {}
neighbors['M'] = ['E', 'B', 'C', 'CS', 'G']
neighbors['E'] = ['M', 'B', 'C', 'CS', 'G', 'P', 'H']
neighbors['B'] = ['M', 'E', 'C', 'CS', 'G', 'P', 'S', 'H', 'F']
neighbors['C'] = ['M', 'E', 'B', 'CS', 'P', 'F']
neighbors['CS'] = ['M', 'E', 'B', 'C', 'G', 'P', 'H', 'F']
neighbors['G'] = ['M', 'E', 'B', 'CS', 'P', 'S', 'H']
neighbors['P'] = ['E', 'B', 'C', 'CS', 'G', 'S', 'H', 'F']
neighbors['S'] = ['B', 'G', 'P', 'H']
neighbors['H'] = ['E', 'B', 'CS', 'P', 'F', 'G']
neighbors['F'] = ['B', 'C', 'CS', 'P', 'H']
I want to convert this code in django models dynamically.
Suppose we get all subjects from django models like this
subjects = Subjects.objects.all()
and then want to make
neighbors lists like above code. So how we can do that
What I have tried:
I want to make a lists of list by using single list. Please help me.