请参阅以下 Django 模型:-
class Student(models.Model):
reference_num = models.CharField(max_length=50, unique=True)
name = models.CharField(max_length=50)
birthdate = models.DateField(null=True, blank=True)
is_active = models.BooleanField(db_index=True)
class Examination(models.Model):
short_name = models.CharField(max_length=20, unique=True)
name = models.CharField(max_length=50, unique=True)
is_active = models.BooleanField(db_index=True)
class Subject(models.Model):
short_name = models.CharField(max_length=20, unique=True)
name = models.CharField(max_length=50, unique=True)
is_active = models.BooleanField(db_index=True)
class EducationalQualification(models.Model):
student = models.ForeignKey(Student)
examination = models.ForeignKey(Examination)
subject = models.ForeignKey(Subject, null=True, blank=True)
institution = models.CharField(max_length=50)
from_date = models.DateField(null=True, blank=True)
to_date = models.DateField()
marks = models.DecimalField(max_digits=5, decimal_places=2)
我需要在网格中显示给定学生的最后一个模型“EducationalQualification”(一个学生可以有多个 EducationalQualifications)。
网格包含“学生姓名”、“考试简称”、“学科简称”、“EducationalQualification.institution”、“EducationalQualification.from_date”、“EducationalQualification.to_date”和“EducationalQualification.marks”列。
我一直无法想出一个 Django 视图来获取这些数据(给定一个 Student.pk)
有人可以帮我一些想法吗?
问候。