Reputation: 45
This picture below illustrate all what I want to implement in the Database. Please I don't know how to connect the Unit and Course_code fields in the model with each course in the choice field.... Students can enroll all Courses in the Turple
model.py
class Course(models.Model):
COURSES_CHOICES = (
('analysis', 'Analysis'),
('numerical', 'Numerical'),
('philosophy', 'Philosophy'),
)
course_names = models.Charfield(choices=COURSES_CHOICES, null=True,)
course_code = models.CharField(max_length=40)
couse_unit = models.intergerField()
class Department(models.Model):
name = models.Charfield(max_length=30)
student = models.ForeignKey(User)
course = models.ManyToManyField(Course)
I dont know if am right with my model.py... Am still a learner in Django
Upvotes: 1
Views: 605
Reputation: 802
I think this might solve what you want to do.
class Department(models.Model):
name = models.Charfield(max_length=30)
student = models.ForeignKey(User)
course = models.ForeignKey(
to='Course',
on_delete=models.CASCADE,
)
Upvotes: 1