I tried reading documents and previous answers to this question without much luck.
I have a bunch of student enrollment enrollments, and I would like to see some of these selected enrollments in combination with some student attributes. So far no luck ... I would ask for your advice!
Here is the model:
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)
and here is table.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',)
As long as I get attendance data, nothing comes from student foreign columns.
netID First Last Attendance M Attendance Tu — — — ✔ ✘
And this is the same transaction, if I run the table using the model = Student and use accessors against the registration table, this is the same transaction.
I feel that I am missing something very conceptual and crucial - please guide me!
source share