我已经尝试过阅读文档和以前对这个问题的答案而没有太多运气.
我有一堆学生课程注册,我希望看到一些选定的注册与学生的一些属性相结合.到目前为止没有运气......我会请求你的建议!
这是模型:
class Student(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
netID = models.CharField(max_length=8)
class Registration(models.Model):
student = models.ForeignKey(Student)
course = models.ForeignKey(Course)
attendance_M = models.BooleanField(default=False)
attendance_Tu = models.BooleanField(default=False)
Run Code Online (Sandbox Code Playgroud)
这是tables.py:
class AttendanceTable(tables.Table):
netID = tables.Column(accessor='Student.netID')
first = tables.Column(accessor='Student.first_name')
last = tables.Column(accessor='Student.last_name')
class Meta:
model = Registration
attrs = {"class": "paleblue"}
fields = ('attendance_M', 'attendance_Tu',)
sequence = ('netID', 'first', 'last', 'attendance_M', 'attendance_Tu',)
Run Code Online (Sandbox Code Playgroud)
虽然我正在获取出勤率值的数据,但学生的外国专栏中没有任何内容.
netID First Last Attendance M Attendance Tu
— — — ? ?
Run Code Online (Sandbox Code Playgroud)
如果我使用model = Student启动Table并对Registration表使用访问器,这是同样的交易,这是相同的交易.
我觉得我错过了很有概念性和关键性的东西 - …