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