From 07c57238a9bcd8d1ca005a107c833af3075dea89 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 7 Jul 2023 01:25:15 +0800 Subject: [PATCH] Fixed study group message serializer --- stude/studygroup_messages/serializers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stude/studygroup_messages/serializers.py b/stude/studygroup_messages/serializers.py index 5222e89..89b11da 100644 --- a/stude/studygroup_messages/serializers.py +++ b/stude/studygroup_messages/serializers.py @@ -1,13 +1,14 @@ from rest_framework import serializers from .models import Message from accounts.models import CustomUser +from study_groups.models import StudyGroup class MessageSerializer(serializers.ModelSerializer): user = serializers.SlugRelatedField( - queryset=CustomUser.objects.all(), slug_field='full_name', required=False) - study_group = serializers.CharField( - source='subject.Subject', read_only=True, required=False) + queryset=CustomUser.objects.all(), slug_field='full_name', required=True) + study_group = serializers.SlugRelatedField( + queryset=StudyGroup.objects.all(), slug_field='name', required=True) class Meta: model = Message