Fixed study group message serializer

This commit is contained in:
Keannu Bernasol 2023-07-07 01:25:15 +08:00
parent 288a1edd5e
commit 07c57238a9

View file

@ -1,13 +1,14 @@
from rest_framework import serializers from rest_framework import serializers
from .models import Message from .models import Message
from accounts.models import CustomUser from accounts.models import CustomUser
from study_groups.models import StudyGroup
class MessageSerializer(serializers.ModelSerializer): class MessageSerializer(serializers.ModelSerializer):
user = serializers.SlugRelatedField( user = serializers.SlugRelatedField(
queryset=CustomUser.objects.all(), slug_field='full_name', required=False) queryset=CustomUser.objects.all(), slug_field='full_name', required=True)
study_group = serializers.CharField( study_group = serializers.SlugRelatedField(
source='subject.Subject', read_only=True, required=False) queryset=StudyGroup.objects.all(), slug_field='name', required=True)
class Meta: class Meta:
model = Message model = Message