Sir, I am trying to make students and courses relationship but cannot do that
Thats the Students Model:
class Student(models.Model):
GENDER = (
('F', 'Female'),
('M', 'Male'),
('O', 'Other'),
)
std_ID = models.CharField(max_length=12, primary_key=True, default='16201519-001')
std_name = models.CharField(max_length=50, default='')
std_gender = models.CharField(max_length=1, choices=GENDER, default='M')
std_class = models.CharField(max_length=50, default='')
Thats the Courses Model:
class Courses(models.Model):
Credits = (
('1', 'One'),
('2', 'Two'),
('3', 'three'),
('4', 'four'),
('6', 'Six'),
)
c_code = models.CharField(max_length=20, primary_key=True, default='CS-202')
c_name = models.CharField(max_length=50)
c_creditsHours = models.CharField(max_length=1, choices=Credits)
courses = models.ManyToManyField(Courses)
What I have tried:
Here you can see, I am using ManyToManyField but when
First, I use the ManyToManyField, then thats show the relation ship in the side of courses but not at person side.
Second, by using the ManyToManyField, All the students already selected but i want to select some of them but cannot do that.
So please tell me how we can do that.