I have a field that has 1000 rows. In these rows there are 2 status available. Present and Absent. I want to know if there's a query expression to count the total number of students present or absent from the Attendence field so that i can store the answers in the respective fields (Attendance field has been populated with 'Present' and 'Absent').
class StudentInClass(models.Model):
Attendance = models.CharField(max_length=20, default='None')
Total_Present = models.IntegerField
Total_Absent = models.IntegerField
I got it working with these commands but these are not what i exactly wanted. If there is an expression query for this then please let me know.
present_count = StudentInClass.objects.filter(Attendance__contains='Present').count
absent_count = StudentInClass.objects.filter(Attendance__contains='Absent').count