From 864643278c37d8313e27656ad07b1d9331242541 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sat, 22 Apr 2023 13:07:47 +0800 Subject: [PATCH] Fixed serializer field for subject on ScheduleSerializer --- infotech/schedules/serializers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infotech/schedules/serializers.py b/infotech/schedules/serializers.py index 7c94c8a..950f37c 100644 --- a/infotech/schedules/serializers.py +++ b/infotech/schedules/serializers.py @@ -1,6 +1,7 @@ from rest_framework import serializers from .models import Schedule from professors.models import Professor +from subjects.models import Subject from students.models import Student @@ -14,6 +15,9 @@ class ScheduleSerializer(serializers.HyperlinkedModelSerializer): professor = serializers.SlugRelatedField( queryset=Professor.objects.all(), slug_field='full_name', allow_null=True) + subject = serializers.SlugRelatedField( + queryset=Subject.objects.all(), slug_field='code', allow_null=True) + class Meta: model = Schedule fields = ('id', 'subject', 'students_assigned',