我想插入多个学生标记记录,但是Django默认提供一对一的学生插入标记。
class ODE_Registation_Model(models.Model):
student = models.ForeignKey(User,on_delete=models.CASCADE)
subject = models.ForeignKey(SubjectMaster,on_delete=models.CASCADE)
ode = models.ForeignKey(ODE_List_Model,on_delete = models.CASCADE,verbose_name="which ode")
exam_date = models.DateField()
registration_date = models.DateField()
def __str__(self):
return self.student.username
class ODE_Marks_Model(models.Model):
ode_registered = models.OneToOneField(ODE_Registation_Model,on_delete=models.CASCADE)
marks = models.SmallIntegerField()
verified_by = models.ForeignKey(User,on_delete=models.CASCADE)
def __str__(self):
return str(self.marks)
我的期望:
显示所有在“ ODE_Registation_Model”中注册的学生姓名和分数(作为输入字段)
ie:-
student marks
stu1 [input type=number]
stu2 [input type=number]
stu3 [input type=number]
... ...