StudE-Backend/stude/studygroup_messages/serializers.py

16 lines
521 B
Python
Raw Normal View History

from rest_framework import serializers
from .models import Message
from accounts.models import CustomUser
2023-07-07 01:25:15 +08:00
from study_groups.models import StudyGroup
class MessageSerializer(serializers.ModelSerializer):
user = serializers.SlugRelatedField(
2023-07-07 01:25:15 +08:00
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
fields = '__all__'