I want to create a website for students with django.
I have learning_plan with n subjects
When I create a student I want to choose an existing learning_plan and have automatic all the subjects that the learning_plan has, also I want to have exam_grades different for each student.
What I’ve done so far:
class Subject(models.Model):
name = models.CharField(max_length=60)
def __unicode__(self):
return self.name
class LearningPlan(models.Model):
name = models.CharField(max_length=60)
subjects = models.ManyToManyField(Subject, through='Exam')
def __unicode__(self):
return self.name
class Student(models.Model):
name = models.CharField(max_length=60)
learning_plan = models.ForeignKey(LearningPlan)
def __unicode__(self):
return self.name
class Exam(models.Model):
subject = models.ForeignKey(Subject)
learning_plan = models.ForeignKey(LearningPlan)
exam_grade = models.IntegerField()
I know what I want I do not know how to do it. I want to have a plan with Subjects: Subject1, Subject2, Subject3 … and when I add a new student I select a plan and see all the subjects from the grade associated to the student and to can add exam_grade to each of the Subjects (Subeject1, Subject2, Subject3 …) and the grades for the same subject to be different for different students. I do not know how to implement this.
If you have a student and what to get his (her) subjects, use this:
Exam grades are simple too, but it’s better to add
related_namefirst:Now you can get student’s exams:
And if you want to add an exam, it’s still simple: