From 83b817ec354a741af3fe961750f9c0a99ce2baf7 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Tue, 25 Jul 2023 17:03:05 +0800 Subject: [PATCH] Improved subject viewset --- stude/subjects/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stude/subjects/views.py b/stude/subjects/views.py index 6e3286f..f0493a2 100644 --- a/stude/subjects/views.py +++ b/stude/subjects/views.py @@ -17,7 +17,7 @@ class SubjectByCourseView(generics.ListAPIView): def get(self, request, course_slug): # Retrieve the subjects based on year level and semester slugs subjects = Subject.objects.filter( - courses__shortname=course_slug).order_by('-subjectyearlevel') + courses__shortname=course_slug).distinct() # Serialize the subjects serializer = SubjectSerializer(subjects, many=True) @@ -32,7 +32,7 @@ class SubjectByCourseYearSemesterView(generics.ListAPIView): def get(self, request, course_slug, year_slug, semester_slug): # Retrieve the subjects based on year level and semester slugs subjects = Subject.objects.filter( - courses__shortname=course_slug, year_levels__shortname=year_slug, semesters__shortname=semester_slug) + courses__shortname=course_slug, year_levels__shortname=year_slug, semesters__shortname=semester_slug).distinct() # Serialize the subjects serializer = SubjectSerializer(subjects, many=True)