[Answered ]-DoesNotExist โ€“ matching query does not exist

1๐Ÿ‘

โœ…

You can check if the values are not None, in case they are, you need to return another queryset of AttendanceLogs (for example AttendanceLog.objects.all() or AttendanceLog.objects.none()):

class AttendanceList(LoginRequiredMixin, ListView):
    model = AttendanceLog
    template_name = "./attendancecode/showattendance.html"

    def get_queryset(self):
       class_val = self.request.GET.get('class')
       subject_val = self.request.GET.get('subject')
       if class_val is not None and subject_val is not None:
           sub = Subject.objects.get(name=subject_val).id
           return get_statstic(class_val, sub)
       # return another queryset:
       return AttendanceLog.objects.none()

    # โ€ฆ

Leave a comment