Hello I have two models Teaching Semester and Enrollments , i wanted to count the number of students in a particular course. Practically i wanted to have a registered students field which will be increased everytime when Enrollments object is created. Here is my model for Teaching Semester
class TeachingSemester(models.Model):
department = models.ForeignKey(Department,on_delete=models.CASCADE)
program = models.ForeignKey(Program,on_delete=models.CASCADE)
faculty = models.ForeignKey(FacultyData,on_delete=models.CASCADE)
semester_choices = (
('Spring' , 'Spring'),
('Fall' , 'Fall'),
('Summer' , 'Summer')
)
sem_choice = models.CharField(max_length=30,choices=semester_choices,default='Spring')
course_date = models.DateField(default=datetime.date.today())
section = models.CharField(max_length=5,default = 1)
faculty_course = models.ForeignKey(Course,on_delete=models.CASCADE)
And model of Enrollments
class Enrollment(models.Model):
student = models.ForeignKey(StudentData,on_delete=models.CASCADE)
faculty = models.ForeignKey(TeachingSemester,on_delete=models.CASCADE)